Skip to content

Settings#

Ruff Language Server には、その動作をカスタマイズするための一連の設定オプションと、既存のpyproject.tomlまたはruff.tomlファイルを使用してスクリーンとフォーマッタを設定する機能が用意されています。これは、サーバの初期化中にこれらの設定を提供することによって行われます。

VS Code は、これらの設定を構成するための UI を提供しますが、他のエディタでは手動構成が必要な場合があります。setupセクションには、エディタごとにこれらの設定を配置する場所に関する指示が記載されています。

Top-level#

configuration#

設定に使用するruff.tomlまたはpyproject.tomlファイルへのパス。

デフォルトでは、Ruff はファイルシステムから各プロジェクトの構成を検出し、Ruff CLI の動作をミラーリングします。

Default value: null

Type: string

Example usage:

json { "ruff.configuration": "~/path/to/ruff.toml" }

lua require('lspconfig').ruff.setup { init_options = { settings = { configuration = "~/path/to/ruff.toml" } } }

configurationPreference#

VS Code とファイルシステムの間で設定を解決するときに使用する戦略。デフォルトでは、エディタ設定はruff.tomlおよびpyproject.tomlファイルよりも優先されます。

  • "editorFirst": エディタの設定は、ワークスペースに存在する設定ファイルよりも優先されます。
  • "filesystemFirst": ワークスペースに存在する設定ファイルは、エディタの設定よりも優先されます。
  • "editorOnly": 設定ファイルを完全に無視します。つまり、エディタの設定のみを使用します。

Default value: "editorFirst"

Type: "editorFirst" | "filesystemFirst" | "editorOnly"

Example usage:

json { "ruff.configurationPreference": "filesystemFirst" }

lua require('lspconfig').ruff.setup { init_options = { settings = { configurationPreference = "filesystemFirst" } } }

exclude#

リンティングとフォーマットから除外するファイルパターンのリスト。詳細については、the documentationを参照してください。

Default value: null

Type: string[]

Example usage:

json { "ruff.exclude": ["**/tests/**"] }

lua require('lspconfig').ruff.setup { init_options = { settings = { exclude = ["**/tests/**"] } } }

lineLength#

リンタおよびフォーマッタに使用する行の長さ。

Default value: null

Type: int

Example usage:

json { "ruff.lineLength": 100 }

lua require('lspconfig').ruff.setup { init_options = { settings = { lineLength = 100 } } }

fixAll#

source.fixAllコードアクションを処理できるようにサーバーを登録するかどうか。

Default value: true

Type: bool

Example usage:

json { "ruff.fixAll": false }

lua require('lspconfig').ruff.setup { init_options = { settings = { fixAll = false } } }

organizeImports#

サーバーがsource.organizeImportsコードアクションを処理できるように登録するかどうか。

Default value: true

Type: bool

Example usage:

json { "ruff.organizeImports": false }

lua require('lspconfig').ruff.setup { init_options = { settings = { organizeImports = false } } }

showSyntaxErrors#

Ruff[v0.5.0]の新機能(https://astral.sh/blog/ruff-v0.5.0#changes-to-e999-and-reporting-of-syntax-errors)

構文エラーの診断を表示するかどうか。

Default value: true

Type: bool

Example usage:

json { "ruff.showSyntaxErrors": false }

lua require('lspconfig').ruff.setup { init_options = { settings = { showSyntaxErrors = false } } }

logLevel#

サーバに使用するログレベル。

Default value: "info"

Type: "trace" | "debug" | "info" | "warn" | "error"

Example usage:

json { "ruff.logLevel": "debug" }

lua require('lspconfig').ruff.setup { init_options = { settings = { logLevel = "debug" } } }

logFile#

サーバに使用するログファイルへのパス。

設定されていない場合、ログは stderr に書き込まれます。

Default value: null

Type: string

Example usage:

json { "ruff.logFile": "~/path/to/ruff.log" }

lua require('lspconfig').ruff.setup { init_options = { settings = { logFile = "~/path/to/ruff.log" } } }

codeAction#

サーバーによって提供されるコードアクションを有効または無効にします。

disableRuleComment.enable#

noqa抑制コメントを使用してルールを無効にするためのクイック修正アクションを表示するかどうか。

Default value: true

Type: bool

Example usage:

json { "ruff.codeAction.disableRuleComment.enable": false }

lua require('lspconfig').ruff.setup { init_options = { settings = { codeAction = { disableRuleComment = { enable = false } } } } }

fixViolation.enable#

Autofix 違反に対する Quick Fix アクションを表示するかどうか。

Default value: true

Type: bool

Example usage:

json { "ruff.codeAction.fixViolation.enable": false }

lua require('lspconfig').ruff.setup { init_options = { settings = { codeAction = { fixViolation = { enable = false } } } } }

lint#

Ruff リンターに固有の設定です。

enable#

リンティングを有効にするかどうか。Ruff をフォーマッタとして排他的に使用するには、falseに設定します。

Default value: true

Type: bool

Example usage:

json { "ruff.lint.enable": false }

lua require('lspconfig').ruff.setup { init_options = { settings = { lint = { enable = false } } } }

preview#

リンティング時に Ruff のプレビューモードを有効にするかどうかを指定します。

Default value: null

Type: bool

Example usage:

json { "ruff.lint.preview": true }

lua require('lspconfig').ruff.setup { init_options = { settings = { lint = { preview = true } } } }

select#

デフォルトで有効にするルール。the documentationを参照してください。

Default value: null

Type: string[]

Example usage:

json { "ruff.lint.select": ["E", "F"] }

lua require('lspconfig').ruff.setup { init_options = { settings = { lint = { select = {"E", "F"} } } } }

extendSelect#

lint.select内のルールに加えて有効にするルール。

Default value: null

Type: string[]

Example usage:

json { "ruff.lint.extendSelect": ["W"] }

lua require('lspconfig').ruff.setup { init_options = { settings = { lint = { extendSelect = {"W"} } } } }

ignore#

デフォルトで無効にするルール。the documentationを参照してください。

Default value: null

Type: string[]

Example usage:

json { "ruff.lint.ignore": ["E4", "E7"] }

lua require('lspconfig').ruff.setup { init_options = { settings = { lint = { ignore = {"E4", "E7"} } } } }

extendIgnore#

lint.ignoreのルールに加えて、無効にするルール。

Default value: null

Type: string[]

Example usage:

json { "ruff.lint.extendIgnore": ["W1"] }

lua require('lspconfig').ruff.setup { init_options = { settings = { lint = { extendIgnore = {"W1"} } } } }

format#

Ruff フォーマッタに固有の設定です。

preview#

書式設定時に Ruff のプレビューモードを有効にするかどうか。

Default value: null

Type: bool

Example usage:

json { "ruff.format.preview": true }

lua require('lspconfig').ruff.setup { init_options = { settings = { format = { preview = true } } } }

VS Code specific#

さらに、Ruff 拡張機能は、VS Code に固有の次の設定を提供します。これらの設定は言語サーバでは使用されず、拡張機能にのみ関連します。

enable#

Ruff 拡張を有効にするかどうか。この設定を変更するには、VS Code を再起動する必要があります。

Default value: true

Type: bool

Example usage:

{
  "ruff.enable": false
}

format.args#

この設定は、ネイティブ言語サーバでは使用されません。

Ruff フォーマッタに渡す追加の引数。

Default value: []

Type: string[]

Example usage:

{
  "ruff.format.args": ["--line-length", "100"]
}

ignoreStandardLibrary#

この設定は、ネイティブ言語サーバでは使用されません。

Python 標準ライブラリの一部であると推測されるファイルを無視するかどうか。

Default value: true

Type: bool

Example usage:

{
  "ruff.ignoreStandardLibrary": false
}

importStrategy#

ruff実行可能ファイルをロードする方法。

  • fromEnvironmentは環境内の Ruff を見つけ、バンドルされたバージョンに戻します。
  • useBundledは、拡張機能にバンドルされているバージョンを使用します。

Default value: "fromEnvironment"

Type: "fromEnvironment" | "useBundled"

Example usage:

{
  "ruff.importStrategy": "useBundled"
}

interpreter#

Python インタプリタへのパスのリスト。これがリストであっても、最初のインタプリタだけが使用されます。

この設定は、ruff.nativeServerの設定によって異なります。:

  • ネイティブサーバを使用している場合、ruff.importStrategyfromEnvironmentに設定されていると、インタプリタを使用してruff実行可能ファイルが検索されます。
  • それ以外の場合は、インタプリタを使用してruff-lspサーバを実行します。

Default value: []

Type: string[]

Example usage:

{
  "ruff.interpreter": ["/home/user/.local/bin/python"]
}

lint.args#

この設定は、ネイティブ言語サーバでは使用されません。

Ruff リンターに渡す追加の引数。

Default value: []

Type: string[]

Example usage:

{
  "ruff.lint.args": ["--config", "/path/to/pyproject.toml"]
}

lint.run#

この設定は、ネイティブ言語サーバでは使用されません。

キーストロークごと(onType)または保存時(onSave)に Ruff を実行します。

Default value: "onType"

Type: "onType" | "onSave"

Example usage:

{
  "ruff.lint.run": "onSave"
}

nativeServer#

ネイティブ言語サーバーruff-lspを使用するか、Ruff のバージョンと拡張機能の設定に基づいて自動的にどちらを使用するかを決定します。

  • "on": ネイティブ言語サーバーを使用します。推奨されない設定が検出されると、警告が表示されます。
  • "off": ruff-lspを使用してください。ネイティブサーバー固有の設定が検出されると、警告が表示されます。
  • "auto": 次の条件に基づいて、母国語サーバーとruff-lspのいずれかを自動的に選択します:
  • Ruff のバージョンが>=0.5.3の場合、推奨されない設定が検出されない限り、ネイティブ言語サーバーを使用します。その場合は、警告を表示し、代わりにruff-lspを使用します。
  • Ruff のバージョンが\<0.5.3の場合は、ruff-lspを使用してください。ネイティブサーバー固有の設定が検出されると、警告が表示されます。
  • true: onと同じです。
  • false: offと同じです。

Default value: "auto"

Type: "on" | "off" | "auto" | true | false

Example usage:

{
  "ruff.nativeServer": "on"
}

path#

A list of path to ruff executables.

ruff実行可能ファイルへのパスのリスト。

存在するリスト内の最初の実行可能ファイルが使用されます。この設定は、ruff.importStrategy設定よりも優先されます。

Default value: []

Type: string[]

Example usage:

{
  "ruff.path": ["/home/user/.local/bin/ruff"]
}

showNotifications#

通知をいつ表示するかを制御する設定。

Default value: "off"

Type: "off" | "onError" | "onWarning" | "always"

Example usage:

{
  "ruff.showNotifications": "onWarning"
}

trace.server#

言語サーバーのトレースレベル。詳細については、LSPspecificationを参照してください。

Default value: "off"

Type: "off" | "messages" | "verbose"

Example usage:

{
  "ruff.trace.server": "messages"
}