From 07e820ac00060ee328504da94f281ce9fe9c7c30 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 10 Jun 2025 14:55:45 +0200 Subject: [PATCH] nvim: Move ruff/pyright lsp settings into after/lsp/ dir --- nvim/.config/nvim/after/lsp/basedpyright.lua | 22 ++++++++++++ nvim/.config/nvim/after/lsp/ruff.lua | 9 +++++ nvim/.config/nvim/lua/plugins/lsp.lua | 37 -------------------- 3 files changed, 31 insertions(+), 37 deletions(-) create mode 100644 nvim/.config/nvim/after/lsp/basedpyright.lua create mode 100644 nvim/.config/nvim/after/lsp/ruff.lua diff --git a/nvim/.config/nvim/after/lsp/basedpyright.lua b/nvim/.config/nvim/after/lsp/basedpyright.lua new file mode 100644 index 0000000..84d1033 --- /dev/null +++ b/nvim/.config/nvim/after/lsp/basedpyright.lua @@ -0,0 +1,22 @@ +-- ensure python virtualenv is determined automatically on lsp start +-- we primarily use pyright for cmp lsp completion & hover info +return { + on_attach = function(client, _) + require("core.util").set_python_env() + local python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) + client.config.settings.python = {} or client.config.settings.python + client.config.settings.python.pythonPath = python_path + end, + settings = { + -- disable imports and linting since, using ruff for it + pyright = { + disableOrganizeImports = true, + }, + python = { + analysis = { + -- ignore all files, use ruff for linting + ignore = { "*" }, + }, + }, + }, +} diff --git a/nvim/.config/nvim/after/lsp/ruff.lua b/nvim/.config/nvim/after/lsp/ruff.lua new file mode 100644 index 0000000..b3fbdb6 --- /dev/null +++ b/nvim/.config/nvim/after/lsp/ruff.lua @@ -0,0 +1,9 @@ +return { + on_attach = function(client, _) + require("core.util").set_python_env() + client.server_capabilities.hoverProvider = false -- we use pyright for hover info + local python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) + client.config.settings.python = {} or client.config.settings.python + client.config.settings.python.pythonPath = python_path + end, +} diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua index 3f6151b..291cdb6 100644 --- a/nvim/.config/nvim/lua/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -137,43 +137,6 @@ local lsp = { end, }) - local python_path - -- ensure python virtualenv is determined automatically on lsp start - -- we primarily use pyright for cmp lsp completion & hover info - register("basedpyright", { - on_attach = function(client, _) - require("core.util").set_python_env() - if python_path == nil then - python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) - end - client.config.settings.python = {} or client.config.settings.python - client.config.settings.python.pythonPath = python_path - end, - settings = { - -- disable imports and linting since, using ruff for it - pyright = { - disableOrganizeImports = true, - }, - python = { - analysis = { - -- ignore all files, use ruff for linting - ignore = { "*" }, - }, - }, - }, - }) - register("ruff", { - on_attach = function(client, _) - require("core.util").set_python_env() - client.server_capabilities.hoverProvider = false -- we use pyright for hover info - if python_path == nil then - python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) - end - client.config.settings.python = {} or client.config.settings.python - client.config.settings.python.pythonPath = python_path - end, - }) - -- set up arduino with the help of arduino.nvim plugin if require("core.util").is_available("arduino") then register("arduino_language_server", {