Use ruff
This commit is contained in:
parent
ddf8072881
commit
787ed309f9
4 changed files with 30 additions and 5 deletions
|
@ -2,7 +2,6 @@ require('nvim-format-buffer').setup({
|
|||
verbose = false,
|
||||
format_rules = {
|
||||
{ pattern = { '*.c', '*.h' }, command = 'clang-format' },
|
||||
{ pattern = { '*.py', '*.pyi' }, command = 'black -q --stdin-filename % - 2>/dev/null | isort -q - 2>/dev/null' },
|
||||
{
|
||||
pattern = { '*.js', '*.mjs', '*.ts', '*.mts', '*.tsx', '*.vue', '*.css' },
|
||||
command = function()
|
||||
|
|
|
@ -2,6 +2,7 @@ require('vim.lsp.log').set_format_func(vim.inspect)
|
|||
-- vim.lsp.set_log_level("debug")
|
||||
|
||||
require("config.lsp.pyright")
|
||||
require("config.lsp.ruff")
|
||||
-- require("config.lsp.pylsp")
|
||||
-- require("config.lsp.typescript")
|
||||
require("config.lsp.clangd")
|
||||
|
@ -26,6 +27,7 @@ local function keymappings(_, bufnr)
|
|||
keymap("n", "gh", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
keymap("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
keymap("n", "gb", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
keymap("n", "ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
|
||||
keymap("n", "gl", "<cmd>lua vim.diagnostic.reset()<CR>", opts)
|
||||
|
||||
|
|
|
@ -3,11 +3,7 @@ local cmd = { bin_name, "--stdio", }
|
|||
|
||||
local root_files = {
|
||||
"pyproject.toml",
|
||||
"setup.py",
|
||||
"setup.cfg",
|
||||
"requirements.txt",
|
||||
"Pipfile",
|
||||
"pyrightconfig.json",
|
||||
".git",
|
||||
}
|
||||
|
||||
|
|
28
lua/config/lsp/ruff.lua
Normal file
28
lua/config/lsp/ruff.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local bin_name = "ruff"
|
||||
local cmd = { bin_name, "server", }
|
||||
|
||||
local root_files = {
|
||||
"pyproject.toml",
|
||||
"requirements.txt",
|
||||
".git",
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "python",
|
||||
callback = function()
|
||||
vim.lsp.start({
|
||||
name = "ruff-server",
|
||||
cmd = cmd,
|
||||
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
|
||||
settings = {
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = { "*.py", "*.pyi" },
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ timeout_ms = 2000 })
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
Loading…
Reference in a new issue