LSP stuff
This commit is contained in:
parent
ff5d0a1d45
commit
525dbfb3a7
|
@ -7,3 +7,12 @@ let g:airline_symbols.branch = ''
|
||||||
let g:airline_symbols.readonly = ''
|
let g:airline_symbols.readonly = ''
|
||||||
let g:airline_symbols.linenr = ''
|
let g:airline_symbols.linenr = ''
|
||||||
let g:airline_section_z = ''
|
let g:airline_section_z = ''
|
||||||
|
|
||||||
|
function! LspStatus() abort
|
||||||
|
let status = luaeval('require("lsp-status").status()')
|
||||||
|
return trim(status)
|
||||||
|
endfunction
|
||||||
|
call airline#parts#define_function('lsp_status', 'LspStatus')
|
||||||
|
call airline#parts#define_condition('lsp_status', 'luaeval("#vim.lsp.buf_get_clients() > 0")')
|
||||||
|
let g:airline#extensions#nvimlsp#enabled = 0
|
||||||
|
let g:airline_section_warning = airline#section#create_right(['lsp_status'])
|
||||||
|
|
6
init.vim
6
init.vim
|
@ -52,8 +52,9 @@ set suffixes+=.pdf
|
||||||
set wildmenu
|
set wildmenu
|
||||||
set hidden
|
set hidden
|
||||||
|
|
||||||
" set completeopt=menu,noinsert,preview
|
"set completeopt=menu,noinsert,preview
|
||||||
set completeopt=menuone,noinsert,noselect
|
"set completeopt=menuone,noinsert,noselect
|
||||||
|
set completeopt=menu,menuone,noselect
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||||
|
|
||||||
|
@ -177,7 +178,6 @@ let g:localvimrc_sandbox=0
|
||||||
|
|
||||||
lua require("my-lsp")
|
lua require("my-lsp")
|
||||||
lua require("lsputils")
|
lua require("lsputils")
|
||||||
"lua require("conf.compe")
|
|
||||||
lua require("conf.cmp")
|
lua require("conf.cmp")
|
||||||
lua require("conf.trouble")
|
lua require("conf.trouble")
|
||||||
" vi:foldmethod=marker sw=2
|
" vi:foldmethod=marker sw=2
|
||||||
|
|
|
@ -13,12 +13,19 @@ cmp.setup({
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
select = true,
|
select = true,
|
||||||
}),
|
}),
|
||||||
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' })
|
['<Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end
|
||||||
},
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'buffer' },
|
--{ name = 'buffer' },
|
||||||
{ name = 'path' },
|
{ name = 'vsnip' },
|
||||||
|
--{ name = 'path' },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
require'compe'.setup {
|
|
||||||
enabled = true;
|
|
||||||
autocomplete = true;
|
|
||||||
debug = false;
|
|
||||||
min_length = 1;
|
|
||||||
preselect = 'enable';
|
|
||||||
throttle_time = 80;
|
|
||||||
source_timeout = 200;
|
|
||||||
resolve_timeout = 800;
|
|
||||||
incomplete_delay = 400;
|
|
||||||
max_abbr_width = 100;
|
|
||||||
max_kind_width = 100;
|
|
||||||
max_menu_width = 100;
|
|
||||||
documentation = {
|
|
||||||
border = { '', '' ,'', ' ', '', '', '', ' ' }, -- the border option is the same as `|help nvim_open_win|`
|
|
||||||
winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder",
|
|
||||||
max_width = 120,
|
|
||||||
min_width = 60,
|
|
||||||
max_height = math.floor(vim.o.lines * 0.3),
|
|
||||||
min_height = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
source = {
|
|
||||||
path = true;
|
|
||||||
buffer = true;
|
|
||||||
calc = true;
|
|
||||||
nvim_lsp = true;
|
|
||||||
nvim_lua = true;
|
|
||||||
vsnip = true;
|
|
||||||
ultisnips = true;
|
|
||||||
luasnip = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
local t = function(str)
|
|
||||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
local check_back_space = function()
|
|
||||||
local col = vim.fn.col('.') - 1
|
|
||||||
return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Use (s-)tab to:
|
|
||||||
--- move to prev/next item in completion menuone
|
|
||||||
--- jump to prev/next snippet's placeholder
|
|
||||||
_G.tab_complete = function()
|
|
||||||
if vim.fn.pumvisible() == 1 then
|
|
||||||
return t "<C-n>"
|
|
||||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
|
||||||
return t "<Plug>(vsnip-expand-or-jump)"
|
|
||||||
elseif check_back_space() then
|
|
||||||
return t "<Tab>"
|
|
||||||
else
|
|
||||||
return vim.fn['compe#complete']()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
_G.s_tab_complete = function()
|
|
||||||
if vim.fn.pumvisible() == 1 then
|
|
||||||
return t "<C-p>"
|
|
||||||
elseif vim.fn['vsnip#jumpable'](-1) == 1 then
|
|
||||||
return t "<Plug>(vsnip-jump-prev)"
|
|
||||||
else
|
|
||||||
-- If <S-Tab> is not working in your terminal, change it to <C-h>
|
|
||||||
return t "<S-Tab>"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
|
||||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
|
||||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
||||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
|
@ -1,8 +1,44 @@
|
||||||
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
|
if vim.fn.has('nvim-0.5.1') == 1 then
|
||||||
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
|
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
|
||||||
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
|
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
|
||||||
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
|
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
|
||||||
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
|
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
|
||||||
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
|
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
|
||||||
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
|
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
|
||||||
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
|
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
|
||||||
|
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
|
||||||
|
else
|
||||||
|
local bufnr = vim.api.nvim_buf_get_number(0)
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions)
|
||||||
|
require('lsputil.codeAction').code_action_handler(nil, actions, nil, nil, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/references'] = function(_, _, result)
|
||||||
|
require('lsputil.locations').references_handler(nil, result, { bufnr = bufnr }, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/definition'] = function(_, method, result)
|
||||||
|
require('lsputil.locations').definition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/declaration'] = function(_, method, result)
|
||||||
|
require('lsputil.locations').declaration_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/typeDefinition'] = function(_, method, result)
|
||||||
|
require('lsputil.locations').typeDefinition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/implementation'] = function(_, method, result)
|
||||||
|
require('lsputil.locations').implementation_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/documentSymbol'] = function(_, _, result, _, bufn)
|
||||||
|
require('lsputil.symbols').document_handler(nil, result, { bufnr = bufn }, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/symbol'] = function(_, _, result, _, bufn)
|
||||||
|
require('lsputil.symbols').workspace_handler(nil, result, { bufnr = bufn }, nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local lspconfig = require('lspconfig')
|
local lsp_status = require('lsp-status')
|
||||||
local configs = require('lspconfig.configs')
|
|
||||||
|
lsp_status.register_progress()
|
||||||
|
|
||||||
-- enable snippet support
|
-- enable snippet support
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
@ -11,6 +12,7 @@ capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
'additionalTextEdits',
|
'additionalTextEdits',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
capabilities = vim.tbl_extend('keep', capabilities or {}, lsp_status.capabilities)
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
|
@ -40,6 +42,9 @@ local on_attach = function(client, bufnr)
|
||||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
buf_set_keymap('n', '<M-q>', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
buf_set_keymap('n', '<M-q>', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
buf_set_keymap("n", "<Leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
buf_set_keymap("n", "<Leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||||
|
|
||||||
|
lsp_status.on_attach(client)
|
||||||
|
|
||||||
--require'completion'.on_attach(client, bufnr)
|
--require'completion'.on_attach(client, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,13 +52,6 @@ local lsp_installer = require("nvim-lsp-installer")
|
||||||
lsp_installer.on_server_ready(function(server)
|
lsp_installer.on_server_ready(function(server)
|
||||||
local opts = {}
|
local opts = {}
|
||||||
|
|
||||||
-- (optional) Customize the options passed to the server
|
|
||||||
-- if server.name == "tsserver" then
|
|
||||||
-- opts.root_dir = function() ... end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- This setup() function is exactly the same as lspconfig's setup function.
|
|
||||||
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
||||||
server:setup(opts)
|
server:setup(opts)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -61,25 +59,13 @@ metals_config = require("metals").bare_config()
|
||||||
metals_config.init_options.statusBarProvider = "on"
|
metals_config.init_options.statusBarProvider = "on"
|
||||||
metals_config.settings = { showImplicitArguments = true }
|
metals_config.settings = { showImplicitArguments = true }
|
||||||
metals_config.on_attach = on_attach
|
metals_config.on_attach = on_attach
|
||||||
|
metals_config.capabilities = capabilities
|
||||||
|
|
||||||
vim.cmd [[augroup lsp]]
|
vim.cmd [[augroup lsp]]
|
||||||
vim.cmd [[au!]]
|
vim.cmd [[au!]]
|
||||||
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]]
|
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]]
|
||||||
vim.cmd [[augroup end]]
|
vim.cmd [[augroup end]]
|
||||||
|
|
||||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
|
||||||
-- map buffer local keybindings when the language server attaches
|
|
||||||
local servers = { "lemminx" }
|
|
||||||
for _, lsp in ipairs(servers) do
|
|
||||||
lspconfig[lsp].setup {
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 150,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
|
@ -88,5 +74,11 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.signature_help, {
|
||||||
|
silent = true, focusable = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]]
|
vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]]
|
||||||
vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float({max_width = 100, focusable = false})]]
|
vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float({max_width = 100, focusable = false})]]
|
||||||
|
|
19
packages.vim
19
packages.vim
|
@ -16,7 +16,7 @@ Plug 'tpope/vim-characterize'
|
||||||
Plug 'tpope/vim-eunuch'
|
Plug 'tpope/vim-eunuch'
|
||||||
Plug 'tpope/vim-commentary'
|
Plug 'tpope/vim-commentary'
|
||||||
Plug 'tpope/vim-sleuth'
|
Plug 'tpope/vim-sleuth'
|
||||||
|
"
|
||||||
" motions and textobjects
|
" motions and textobjects
|
||||||
Plug 'kana/vim-textobj-user'
|
Plug 'kana/vim-textobj-user'
|
||||||
Plug 'glts/vim-textobj-comment'
|
Plug 'glts/vim-textobj-comment'
|
||||||
|
@ -26,18 +26,25 @@ Plug 'vim-scripts/argtextobj.vim'
|
||||||
Plug 'mhinz/vim-signify'
|
Plug 'mhinz/vim-signify'
|
||||||
|
|
||||||
" LSP
|
" LSP
|
||||||
|
Plug 'neovim/nvim-lspconfig'
|
||||||
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||||
|
Plug 'hrsh7th/cmp-buffer'
|
||||||
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
|
Plug 'scalameta/nvim-metals'
|
||||||
|
Plug 'hrsh7th/cmp-vsnip'
|
||||||
|
Plug 'hrsh7th/vim-vsnip'
|
||||||
|
|
||||||
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'williamboman/nvim-lsp-installer'
|
Plug 'williamboman/nvim-lsp-installer'
|
||||||
Plug 'scalameta/nvim-metals'
|
Plug 'scalameta/nvim-metals'
|
||||||
"Plug 'hrsh7th/nvim-compe'
|
|
||||||
Plug 'hrsh7th/nvim-cmp'
|
|
||||||
Plug 'hrsh7th/cmp-buffer'
|
Plug 'hrsh7th/cmp-buffer'
|
||||||
Plug 'hrsh7th/cmp-path'
|
Plug 'hrsh7th/cmp-path'
|
||||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||||
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
|
Plug 'hrsh7th/cmp-vsnip'
|
||||||
Plug 'hrsh7th/vim-vsnip'
|
Plug 'hrsh7th/vim-vsnip'
|
||||||
Plug 'hrsh7th/vim-vsnip-integ'
|
|
||||||
"Plug 'nvim-lua/completion-nvim'
|
"Plug 'nvim-lua/completion-nvim'
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'branch': '0.5-compat', 'do': ':TSUpdate'}
|
Plug 'nvim-treesitter/nvim-treesitter', {'branch': '0.5-compat', 'do': ':TSUpdate'}
|
||||||
Plug 'nvim-lua/lsp-status.nvim'
|
Plug 'nvim-lua/lsp-status.nvim'
|
||||||
|
@ -49,8 +56,6 @@ Plug 'folke/lsp-colors.nvim'
|
||||||
Plug 'nvim-lua/popup.nvim'
|
Plug 'nvim-lua/popup.nvim'
|
||||||
Plug 'nvim-lua/plenary.nvim'
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
Plug 'nvim-telescope/telescope.nvim'
|
Plug 'nvim-telescope/telescope.nvim'
|
||||||
Plug 'L3MON4D3/LuaSnip'
|
|
||||||
|
|
||||||
|
|
||||||
Plug 'machakann/vim-highlightedyank'
|
Plug 'machakann/vim-highlightedyank'
|
||||||
|
|
||||||
|
@ -70,10 +75,10 @@ Plug 'tpope/vim-rails'
|
||||||
Plug 'tpope/vim-rake'
|
Plug 'tpope/vim-rake'
|
||||||
|
|
||||||
" git
|
" git
|
||||||
"Plug 'tpope/vim-fugitive'
|
|
||||||
Plug 'lambdalisue/gina.vim'
|
Plug 'lambdalisue/gina.vim'
|
||||||
Plug 'gregsexton/gitv'
|
Plug 'gregsexton/gitv'
|
||||||
Plug 'gisphm/vim-gitignore'
|
Plug 'gisphm/vim-gitignore'
|
||||||
|
Plug 'sjl/splice.vim'
|
||||||
|
|
||||||
" other filetype specific plugins
|
" other filetype specific plugins
|
||||||
Plug 'jamessan/vim-gnupg'
|
Plug 'jamessan/vim-gnupg'
|
||||||
|
|
Loading…
Reference in a new issue