initial lsp setup
This commit is contained in:
parent
8b05648ca1
commit
3fd34351b9
3 changed files with 82 additions and 162 deletions
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"codeLens.enable": true,
|
||||
"codeLens.position": "top",
|
||||
"coc.preferences.extensionUpdateCheck": "daily",
|
||||
"coc.preferences.enableMessageDialog": true,
|
||||
"coc.preferences.formatOnType": true,
|
||||
"coc.preferences.willSaveHandlerTimeout": 1000,
|
||||
"coc.preferences.enableLinkedEditing": true,
|
||||
"coc.preferences.formatOnSaveFiletypes": [
|
||||
"c",
|
||||
"go",
|
||||
"python",
|
||||
"rust",
|
||||
"markdown",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"json",
|
||||
"jsonc"
|
||||
],
|
||||
"coc.source.file.ignoreHidden": false,
|
||||
"diagnostic.floatConfig": {
|
||||
"rounded": true,
|
||||
"border": true
|
||||
},
|
||||
"diagnostic.autoRefresh": true,
|
||||
"diagnostic.refreshOnInsertMode": true,
|
||||
"diagnostic.format": "[%severity] %message [%source]",
|
||||
"diagnostic.virtualText": true,
|
||||
"diagnostic.level": "hint",
|
||||
"diagnostic.checkCurrentLine": true,
|
||||
"diagnostic.separateRelatedInformationAsDiagnostics": true,
|
||||
"eslint.autoFixOnSave": true,
|
||||
"eslint.format.enable": true,
|
||||
"eslint.packageManager": "yarn",
|
||||
"git.addGBlameToVirtualText": true,
|
||||
"git.blameUseRealTime": true,
|
||||
"hover.floatConfig": {
|
||||
"rounded": true,
|
||||
"border": true
|
||||
},
|
||||
"list.normalMappings": {
|
||||
"<C-c>": "do:exit"
|
||||
},
|
||||
"list.insertMappings": {
|
||||
"<C-c>": "do:exit"
|
||||
},
|
||||
"python.formatting.provider": "yapf",
|
||||
"python.linting.enabled": true,
|
||||
"python.analysis.diagnosticMode": "workspace",
|
||||
"python.linting.pylintEnabled": true,
|
||||
"python.linting.flake8Enabled": true,
|
||||
"python.linting.pylamaEnabled": true,
|
||||
"python.linting.banditEnabled": true,
|
||||
"python.linting.pycodestyleEnabled": true,
|
||||
"python.linting.mypyEnabled": false,
|
||||
"python.linting.pytypeEnabled": true,
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"semanticTokens.enable": true,
|
||||
"signature.target": "echo",
|
||||
"suggest.detailField": "abbr",
|
||||
"suggest.defaultSortMethod": "none",
|
||||
"suggest.selection": "recentlyUsedByPrefix",
|
||||
"suggest.noselect": false,
|
||||
"suggest.floatConfig": {
|
||||
"rounded": true,
|
||||
"border": true
|
||||
},
|
||||
"signature.floatConfig": {
|
||||
"rounded": true,
|
||||
"border": true
|
||||
},
|
||||
"snippet.choicesMenuPicker": true,
|
||||
"languageserver": {
|
||||
"bash": {
|
||||
"command": "bash-language-server",
|
||||
"args": ["start"],
|
||||
"filetypes": ["sh"]
|
||||
},
|
||||
"kotlin": {
|
||||
"command": "kotlin-language-server",
|
||||
"filetypes": ["kotlin"]
|
||||
}
|
||||
},
|
||||
"git.enableGutters": true
|
||||
}
|
81
init.vim
81
init.vim
|
@ -6,15 +6,18 @@ Plug 'nvim-tree/nvim-tree.lua'
|
|||
|
||||
" neovim lsp plugins and depencencies
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
Plug 'williamboman/mason.nvim'
|
||||
Plug 'williamboman/mason-lspconfig.nvim'
|
||||
Plug 'jose-elias-alvarez/null-ls.nvim'
|
||||
|
||||
|
||||
" various plugins
|
||||
Plug 'akinsho/bufferline.nvim', { 'tag': 'v3.*' }
|
||||
Plug 'gorbit99/codewindow.nvim'
|
||||
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
Plug 'preservim/nerdcommenter'
|
||||
Plug 'mhinz/vim-startify'
|
||||
Plug 'rmagatti/auto-session'
|
||||
|
@ -62,14 +65,6 @@ nnoremap <C-t> :NvimTreeToggle<CR>
|
|||
nmap <C-_> <plug>NERDCommenterToggle
|
||||
vmap <C-_> <plug>NERDCommenterToggle
|
||||
|
||||
" saving with Ctrl+s
|
||||
"nnoremap <silent><C-s> :update<cr>
|
||||
"inoremap <silent><C-s> <c-o>:update<cr>
|
||||
"vnoremap <silent><c-s> <c-c>:update<cr>gv " gv to preserve visual selection
|
||||
|
||||
" show uncommited git changes in current part of the code
|
||||
nnoremap <C-g> :CocCommand git.chunkInfo<CR>
|
||||
|
||||
"theme configuration
|
||||
syntax enable
|
||||
let g:onedark_config = {
|
||||
|
@ -102,80 +97,12 @@ imap <S-Tab> <Esc><<i
|
|||
vmap <Tab> >gv
|
||||
vmap <S-Tab> <gv
|
||||
|
||||
" Remap <C-f> and <C-b> for scroll float windows/popups.
|
||||
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
||||
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||
endif
|
||||
|
||||
" Find files using Telescope command-line sugar.
|
||||
nnoremap <leader>ff <cmd>Telescope find_files<cr>
|
||||
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
|
||||
nnoremap <leader>fb <cmd>Telescope buffers<cr>
|
||||
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
|
||||
|
||||
""""""""""""""""""""""""""""
|
||||
" config for coc#pum#visible
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
" Some servers have issues with backup files, see #649.
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
|
||||
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
" delays and poor user experience.
|
||||
set updatetime=300
|
||||
|
||||
" Always show the signcolumn, otherwise it would shift the text each time
|
||||
" diagnostics appear/become resolved.
|
||||
set signcolumn=yes
|
||||
|
||||
|
||||
" Symbol renaming.
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Formatting selected code.
|
||||
xmap <leader>ft <Plug>(coc-format-selected)
|
||||
nmap <leader>ft <Plug>(coc-format-selected)
|
||||
|
||||
" GoTo code navigation.
|
||||
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)
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" NOTE: There's always complete item selected by default, you may want to enable
|
||||
" no select by `"suggest.noselect": true` in your configuration file.
|
||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
" other plugin before putting this into your config.
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ coc#pum#visible() ? coc#pum#next(1) :
|
||||
\ CheckBackspace() ? "\<Tab>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
|
||||
|
||||
" Make <CR> to accept selected completion item or notify coc.nvim to format
|
||||
" <C-g>u breaks current undo, please make your own choice.
|
||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
function! CheckBackspace() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
" Use <c-space> to trigger completion.
|
||||
if has('nvim')
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
else
|
||||
inoremap <silent><expr> <c-@> coc#refresh()
|
||||
endif
|
||||
|
||||
|
||||
" general configs
|
||||
set modeline
|
||||
|
|
|
@ -39,6 +39,13 @@ codewindow.setup({
|
|||
})
|
||||
codewindow.apply_default_keybinds()
|
||||
|
||||
require'lspconfig'.pyright.setup{}
|
||||
require'lspconfig'.bashls.setup{}
|
||||
require'lspconfig'.salt_ls.setup{}
|
||||
require'lspconfig'.dockerls.setup{}
|
||||
require'lspconfig'.kotlin_language_server.setup{}
|
||||
require'lspconfig'.intelephense.setup{}
|
||||
require'lspconfig'.eslint.setup{}
|
||||
|
||||
-- load perl lsp
|
||||
require'lspconfig'.perlnavigator.setup{
|
||||
|
@ -53,6 +60,77 @@ require'lspconfig'.perlnavigator.setup{
|
|||
}
|
||||
}
|
||||
|
||||
-- Set up nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' }, -- For vsnip users.
|
||||
-- { name = 'luasnip' }, -- For luasnip users.
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
-- Set up lspconfig.
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||
require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
require'lspconfig'.tsserver.setup{}
|
||||
|
||||
require("nvim-tree").setup({
|
||||
create_in_closed_folder = true,
|
||||
hijack_cursor = true,
|
||||
|
|
Loading…
Reference in a new issue