lsp changes
This commit is contained in:
parent
93389b7a1c
commit
7ed7144c97
3 changed files with 29 additions and 3 deletions
lua
|
@ -40,8 +40,8 @@ function M.init(client, bufnr)
|
|||
|
||||
-- code actions
|
||||
buf_map('n', '<leader>r', '<cmd>lua vim.lsp.buf.rename()<cr>', { desc = 'Rename' })
|
||||
buf_map('n', '<leader>la', '<cmd>lua vim.lsp.buf.code_actions()<cr>', { desc = 'Code Actions' })
|
||||
buf_map('v', '<leader>la', '<cmd>lua vim.lsp.buf.range_code_actions()<cr>', { desc = 'Range Code Actions' })
|
||||
buf_map('n', '<leader>a', '<cmd>lua vim.lsp.buf.code_action()<cr>', { desc = 'Code Actions' })
|
||||
buf_map('v', '<leader>a', '<cmd>lua vim.lsp.buf.range_code_action()<cr>', { desc = 'Range Code Actions' })
|
||||
|
||||
-- formatting
|
||||
if client.supports_method('textDocument/formatting') then
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
return {
|
||||
rust_analyzer = true,
|
||||
zls = true,
|
||||
clangd = true,
|
||||
erlangls = true,
|
||||
lua_ls = {
|
||||
format_on_save = false,
|
||||
|
@ -11,5 +13,8 @@ return {
|
|||
ts_ls = {
|
||||
format_on_save = false,
|
||||
},
|
||||
tailwindcss = {
|
||||
format_on_save = false,
|
||||
},
|
||||
svelte = true,
|
||||
}
|
||||
|
|
|
@ -17,6 +17,27 @@ local snippet = {
|
|||
end,
|
||||
}
|
||||
|
||||
-- check if the cursor is inside a snippet.
|
||||
local function in_snippet()
|
||||
local session = luasnip.session
|
||||
local node = session.current_nodes[vim.api.nvim_get_current_buf()]
|
||||
if not node then
|
||||
return
|
||||
end
|
||||
local snippet = node.parent.snippet
|
||||
local snip_begin_pos, snip_end_pos = snippet.mark:pos_begin_end()
|
||||
local pos = vim.api.nvim_win_get_cursor(0)
|
||||
if pos[1] - 1 >= snip_begin_pos[1] and pos[1] - 1 <= snip_end_pos[1] then
|
||||
return true -- not on row inside snippet
|
||||
end
|
||||
end
|
||||
|
||||
-- check if snippet is expandable or jumpable.
|
||||
-- Only jumping if the cursor is inside the snippet
|
||||
local function expandable_or_locally_jumpable()
|
||||
return luasnip.expandable() or (in_snippet() and luasnip.jumpable())
|
||||
end
|
||||
|
||||
local cmp_opts = {
|
||||
enabled = function()
|
||||
-- disable completion in comments
|
||||
|
@ -44,7 +65,7 @@ local cmp_opts = {
|
|||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
elseif expandable_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
|
|
Loading…
Add table
Reference in a new issue