Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lua/core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ settings["server_formatting_block_list"] = {
clangd = true,
lua_ls = true,
ts_ls = true,
ruff = false, -- set to false to enable ruff formatting, see discussion #1485
}

-- Directories where formatting on save is disabled.
Expand Down Expand Up @@ -119,8 +120,9 @@ settings["lsp_deps"] = {
"html",
"jsonls",
"lua_ls",
"pylsp",
"gopls",
"pyrefly",
"ruff",
}

-- General-purpose sources for none-ls to install during bootstrap.
Expand Down
63 changes: 0 additions & 63 deletions lua/modules/configs/completion/mason-lspconfig.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
local M = {}

M.setup = function()
local is_windows = require("core.global").is_windows

local lsp_deps = require("core.settings").lsp_deps
local mason_registry = require("mason-registry")
local mason_lspconfig = require("mason-lspconfig")
Expand Down Expand Up @@ -119,67 +117,6 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
for _, pkg in ipairs(mason_registry.get_installed_package_names()) do
setup_lsp_for_package(pkg)
end

-- Hook into Mason's package install event to install extra plugins for pylsp (black, ruff, rope),
-- then configure the installed package's LSP using setup_lsp_for_package.
mason_registry:on(
"package:install:success",
vim.schedule_wrap(function(pkg)
if pkg.name == "python-lsp-server" then
local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv"
local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python"
local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black"
local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff"

require("plenary.job")
:new({
command = python,
args = {
"-m",
"pip",
"install",
"-U",
"--disable-pip-version-check",
"python-lsp-black",
"python-lsp-ruff",
"pylsp-rope",
},
cwd = venv,
env = { VIRTUAL_ENV = venv },
on_exit = function()
if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then
vim.notify(
"Finished installing pylsp plugins",
vim.log.levels.INFO,
{ title = "[lsp] Install Status" }
)
else
vim.notify(
"Failed to install pylsp plugins. [Executable not found]",
vim.log.levels.ERROR,
{ title = "[lsp] Install Failure" }
)
end
end,
on_start = function()
vim.notify(
"Now installing pylsp plugins...",
vim.log.levels.INFO,
{ title = "[lsp] Install Status", timeout = 6000 }
)
end,
on_stderr = function(_, msg_stream)
if msg_stream then
vim.notify(msg_stream, vim.log.levels.ERROR, { title = "[lsp] Install Failure" })
end
end,
})
:start()
end

setup_lsp_for_package(pkg)
end)
)
end

return M
46 changes: 0 additions & 46 deletions lua/modules/configs/completion/servers/pylsp.lua

This file was deleted.

28 changes: 28 additions & 0 deletions lua/modules/configs/completion/servers/ruff.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- https://github.com/neovim/nvim-lspconfig/blob/master/lsp/ruff.lua
return {
cmd = { "ruff", "server" },
filetypes = { "python" },
root_markers = { "pyproject.toml", "ruff.toml", ".ruff.toml", ".git" },

-- the following are added by nvimdots
settings = {
init_options = {
settings = {
lint = {
select = {
-- enable: pycodestyle
"E",
-- enable: pyflakes
"F",
},
extendSelect = {
-- enable: isort
"I",
},
-- the same line length as black
lineLength = 88,
},
},
},
},
}