nvim: Fix LSP tab/enter; Fix multi-LSP formatting; Add ruff and neocmakelsp
This commit is contained in:
parent
17b700c910
commit
d95aefb166
5
nvim/.config/nvim/lsp/neocmakelsp.lua
Normal file
5
nvim/.config/nvim/lsp/neocmakelsp.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
return {
|
||||||
|
cmd = { "neocmakelsp", "--stdio" },
|
||||||
|
filetypes = { "cmake" },
|
||||||
|
root_markers = { ".git", "README.md" }
|
||||||
|
}
|
||||||
33
nvim/.config/nvim/lsp/ruff.lua
Normal file
33
nvim/.config/nvim/lsp/ruff.lua
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
-- return {
|
||||||
|
-- cmd = {
|
||||||
|
-- 'pyright-langserver', '--stdio'
|
||||||
|
-- },
|
||||||
|
-- settings = {
|
||||||
|
-- python = {
|
||||||
|
-- analysis = {
|
||||||
|
-- typeCheckingMode = "basic", -- or "strict", "off"
|
||||||
|
-- autoSearchPaths = true,
|
||||||
|
-- useLibraryCodeForTypes = true,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- root_markers = {
|
||||||
|
-- 'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', '.git'
|
||||||
|
-- },
|
||||||
|
-- filetypes = {
|
||||||
|
-- 'python'
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
return {
|
||||||
|
cmd = {
|
||||||
|
'ruff', 'server'
|
||||||
|
},
|
||||||
|
filetypes = {
|
||||||
|
'python'
|
||||||
|
},
|
||||||
|
root_markers = {
|
||||||
|
'setup.py', 'setup.cfg', 'requirements.txt', '.git', 'ruff.toml'
|
||||||
|
},
|
||||||
|
-- single_file_support = true,
|
||||||
|
-- settings = {},
|
||||||
|
}
|
||||||
@ -20,6 +20,24 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||||||
callback = function(args)
|
callback = function(args)
|
||||||
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
||||||
|
|
||||||
|
-- Make Tab accept the selected completion
|
||||||
|
vim.keymap.set('i', '<Tab>', function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return '<C-y>'
|
||||||
|
else
|
||||||
|
return '<Tab>'
|
||||||
|
end
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
|
-- Make Enter just insert a newline (don't accept completion)
|
||||||
|
vim.keymap.set('i', '<CR>', function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return '<C-e><CR>'
|
||||||
|
else
|
||||||
|
return '<CR>'
|
||||||
|
end
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
|
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
|
||||||
if client:supports_method('textDocument/completion') then
|
if client:supports_method('textDocument/completion') then
|
||||||
-- Trigger autocompletion on EVERY keypress. May be slow!
|
-- Trigger autocompletion on EVERY keypress. May be slow!
|
||||||
@ -30,10 +48,10 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set('n', '<M-L>',
|
vim.keymap.set('n', '<M-L>',
|
||||||
function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) end,
|
function() vim.lsp.buf.format({ bufnr = args.buf, timeout_ms = 1000 }) end,
|
||||||
{ desc = "Format" })
|
{ desc = "Format" })
|
||||||
vim.keymap.set('i', '<M-L>',
|
vim.keymap.set('i', '<M-L>',
|
||||||
function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) end,
|
function() vim.lsp.buf.format({ bufnr = args.buf, timeout_ms = 1000 }) end,
|
||||||
{ desc = "Format" })
|
{ desc = "Format" })
|
||||||
|
|
||||||
-- if client:supports_method('textDocument/implementation') then
|
-- if client:supports_method('textDocument/implementation') then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user