nvim: Fix LSP tab/enter; Fix multi-LSP formatting; Add ruff and neocmakelsp
This commit is contained in:
parent
17b700c910
commit
d03b02e2ca
@ -20,6 +20,24 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
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|
|
||||
if client:supports_method('textDocument/completion') then
|
||||
-- Trigger autocompletion on EVERY keypress. May be slow!
|
||||
@ -30,10 +48,10 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||
end
|
||||
|
||||
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" })
|
||||
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" })
|
||||
|
||||
-- if client:supports_method('textDocument/implementation') then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user