Squashed commit of the following:

commit 35bbfb270aaa17ab0bea37b50f85068b28e1d1a9
Author: Alex Yatskov <alex@foosoft.net>
Date:   Wed Oct 13 20:05:12 2021 -0700

    Disable snippets

commit bc03ffc0c123149fce2c23f29a61c7a7f2d6a730
Author: Alex Yatskov <alex@foosoft.net>
Date:   Wed Oct 13 17:51:23 2021 -0700

    Switch to nvim lsp
This commit is contained in:
Alex Yatskov 2021-10-13 20:06:26 -07:00
parent 90d6d990d5
commit d47e89c0c8
10 changed files with 86 additions and 32 deletions

18
.gitmodules vendored
View File

@ -70,12 +70,24 @@
[submodule ".vim/pack/plugins/start/vim-fugitive"] [submodule ".vim/pack/plugins/start/vim-fugitive"]
path = pack/plugins/start/vim-fugitive path = pack/plugins/start/vim-fugitive
url = https://github.com/tpope/vim-fugitive.git url = https://github.com/tpope/vim-fugitive.git
[submodule "pack/plugins/start/coc.nvim"]
path = pack/plugins/opt/coc.nvim
url = https://github.com/neoclide/coc.nvim
[submodule "pack/plugins/start/vim-rooter"] [submodule "pack/plugins/start/vim-rooter"]
path = pack/plugins/start/vim-rooter path = pack/plugins/start/vim-rooter
url = https://github.com/airblade/vim-rooter.git url = https://github.com/airblade/vim-rooter.git
[submodule "pack/plugins/start/vim-polyglot"] [submodule "pack/plugins/start/vim-polyglot"]
path = pack/plugins/start/vim-polyglot path = pack/plugins/start/vim-polyglot
url = https://github.com/sheerun/vim-polyglot url = https://github.com/sheerun/vim-polyglot
[submodule "pack/plugins/opt/cmp-nvim-lsp"]
path = pack/plugins/opt/cmp-nvim-lsp
url = https://github.com/hrsh7th/cmp-nvim-lsp.git
[submodule "pack/plugins/opt/nvim-lspconfig"]
path = pack/plugins/opt/nvim-lspconfig
url = https://github.com/neovim/nvim-lspconfig.git
[submodule "pack/plugins/opt/nvim-cmp"]
path = pack/plugins/opt/nvim-cmp
url = https://github.com/hrsh7th/nvim-cmp.git
[submodule "pack/plugins/opt/cmp-vsnip"]
path = pack/plugins/opt/cmp-vsnip
url = https://github.com/hrsh7th/cmp-vsnip
[submodule "pack/plugins/opt/vim-vsnip"]
path = pack/plugins/opt/vim-vsnip
url = https://github.com/hrsh7th/vim-vsnip

View File

@ -1,6 +1,2 @@
#!/bin/bash #!/bin/bash
git submodule update --init --recursive git submodule update --init --recursive
pushd ./pack/plugins/opt/coc.nvim/
npm install
npm run build
popd

View File

@ -13,7 +13,6 @@ set background=dark
set backspace=indent,eol,start set backspace=indent,eol,start
set belloff=all set belloff=all
set complete-=i set complete-=i
set completeopt=menuone,noinsert
set encoding=utf-8 set encoding=utf-8
set expandtab set expandtab
set fileformats=unix,dos,mac set fileformats=unix,dos,mac

@ -0,0 +1 @@
Subproject commit f93a6cf9761b096ff2c28a4f0defe941a6ffffb5

@ -0,0 +1 @@
Subproject commit 1588c35bf8f637e8f5287477f31895781858f970

@ -1 +0,0 @@
Subproject commit 03c9add7cd867a013102dcb45fb4e75304d227d7

@ -0,0 +1 @@
Subproject commit f5393d5bd934428a469f03f5bc225922f8c48367

@ -0,0 +1 @@
Subproject commit e4bed57f127310764f08e8b45f1ed3a31c6094e0

@ -0,0 +1 @@
Subproject commit 9ac8044206d32bea4dba34e77b6a3b7b87f65df6

View File

@ -1,31 +1,74 @@
" coc.nvim " cmp-nvim-lsp, nvim-cmp, nvim-lspconfig
if executable('node') if has('nvim')
packadd coc.nvim packadd cmp-nvim-lsp
packadd nvim-cmp
packadd nvim-lspconfig
highlight CocErrorSign ctermfg=Red guifg=#dc322f lua << EOF
highlight CocWarningSign ctermfg=Yellow guifg=#b58900 -- Use an on_attach function to only map the following keys
highlight CocInfoHighlight ctermfg=Blue guifg=#268bd2 -- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
let g:coc_disable_startup_warning = 1 -- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
nmap <silent> [g <Plug>(coc-diagnostic-prev) -- Mappings.
nmap <silent> ]g <Plug>(coc-diagnostic-next) local opts = { noremap=true, silent=true }
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
if has('nvim-0.4.0') || has('patch-8.2.0750') -- See `:help vim.lsp.*` for documentation on any of the below functions
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
endif buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
inoremap <expr><tab> pumvisible() ? '<C-y>' : '<tab>' -- Add additional capabilities supported by nvim-cmp
inoremap <expr><cr> pumvisible() ? '<C-e><cr>' : '<cr>' local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities, {snippetSupport = false})
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local nvim_lsp = require('lspconfig')
for _, lsp in ipairs({'jedi_language_server', 'gopls', 'clangd'}) do
nvim_lsp[lsp].setup({
on_attach = on_attach,
capabilities = capabilities
})
end
-- nvim-cmp setup
local cmp = require('cmp')
cmp.setup {
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.confirm({select = true}),
},
sources = {
{name = 'nvim_lsp'},
},
}
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
EOF
endif endif
" fzf " fzf