Skip to content

Instantly share code, notes, and snippets.

@m-pilia
Last active October 27, 2024 14:32
Show Gist options
  • Save m-pilia/2273f1c53bea11f201985e835706d810 to your computer and use it in GitHub Desktop.
Save m-pilia/2273f1c53bea11f201985e835706d810 to your computer and use it in GitHub Desktop.
Neovim 0.11 built-in LSP autocompletion
-- Built-in autocompletion
local lsp_au_group = vim.api.nvim_create_augroup('lsp_au_group', {clear = true})
vim.api.nvim_create_autocmd({'LspAttach'}, {
callback = function()
local clients = vim.lsp.get_clients()
for _, client in ipairs(clients) do
local id = client.id
vim.lsp.completion.enable(true, id, 0, {autotrigger = true})
end
end,
group = lsp_au_group,
})
require("nvim-autopairs").setup {
map_bs = false,
}
inoremap <silent> <expr> <tab> pumvisible() ? "\<C-n>" : "\<tab>"
inoremap <silent> <expr> <S-tab> pumvisible() ? "\<C-p>" : "\<S-tab>"
inoremap <silent> <C-space> <C-x><C-o>
inoremap <silent> <expr> <C-j> pumvisible() ? "\<C-y>" : "\<C-j>"
inoremap <silent> <expr> <bs> pumvisible() ? "\<bs>\<c-x>\<c-o>"
\ : v:lua.require('nvim-autopairs').autopairs_bs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment