Skip to content

Instantly share code, notes, and snippets.

@saahiluppal
Last active March 30, 2021 08:27
Show Gist options
  • Save saahiluppal/241ba70a3f6cfaaa21420a9373fef757 to your computer and use it in GitHub Desktop.
Save saahiluppal/241ba70a3f6cfaaa21420a9373fef757 to your computer and use it in GitHub Desktop.
" nvim-completion setup
" Tab S-Tab movement
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Config
lua << EOF
require'compe'.setup {
enabled = true;
autocomplete = true;
debug = false;
min_length = 1;
preselect = 'enable';
throttle_time = 80;
source_timeout = 200;
incomplete_delay = 400;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = true;
source = {
path = true;
buffer = true;
calc = true;
nvim_lsp = true;
nvim_lua = true;
vsnip = true;
};
}
EOF
" Mappings
inoremap <silent><expr> <C-Space> compe#complete()
inoremap <silent><expr> <CR> compe#confirm('<CR>')
inoremap <silent><expr> <C-e> compe#close('<C-e>')
"inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
"inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
" LSP Config
" pyright language server is good enough
" install it with `npm i -g pyright`
" gopls language server for go lang
" install it with `GO111MODULE=on go get golang.org/x/tools/gopls@latest`
" find where gopls installed and export it in path
lua << EOF
-- on_attach is for autocompletion
require'lspconfig'.pyright.setup{}
require'lspconfig'.gopls.setup{}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment