mirror of https://github.com/wlcx/home.git
vim: Add lsp completion
This commit is contained in:
parent
9d17d0b0be
commit
74b11aead4
|
@ -18,9 +18,12 @@ in {
|
||||||
[
|
[
|
||||||
# More fancy shit
|
# More fancy shit
|
||||||
nvim-treesitter
|
nvim-treesitter
|
||||||
# Language stuff
|
|
||||||
nvim-lspconfig
|
|
||||||
trouble-nvim
|
trouble-nvim
|
||||||
|
# Language server/completions
|
||||||
|
nvim-lspconfig
|
||||||
|
nvim-cmp
|
||||||
|
cmp-nvim-lsp
|
||||||
|
# Language specific
|
||||||
rust-vim
|
rust-vim
|
||||||
vim-terraform
|
vim-terraform
|
||||||
vim-protobuf
|
vim-protobuf
|
||||||
|
|
|
@ -9,12 +9,35 @@ local on_attach = function(client, bufnr)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable Language LSPs
|
-- Completion
|
||||||
|
local cmp = require'cmp'
|
||||||
|
cmp.setup({
|
||||||
|
window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
}),
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Language servers
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
require'lspconfig'.gopls.setup{
|
require'lspconfig'.gopls.setup{
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
require'lspconfig'.pylsp.setup{
|
require'lspconfig'.pylsp.setup{
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
handlers = {
|
handlers = {
|
||||||
["textDocument/publishDiagnostics"] = vim.lsp.with(
|
["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
|
@ -25,21 +48,26 @@ require'lspconfig'.pylsp.setup{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require'lspconfig'.rnix.setup{
|
require'lspconfig'.rnix.setup{
|
||||||
on_attach = on_attach
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
require'lspconfig'.rust_analyzer.setup{
|
require'lspconfig'.rust_analyzer.setup{
|
||||||
on_attach = on_attach
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
require'lspconfig'.dhall_lsp_server.setup{
|
require'lspconfig'.dhall_lsp_server.setup{
|
||||||
on_attach = on_attach
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
require'lspconfig'.eslint.setup{
|
require'lspconfig'.eslint.setup{
|
||||||
on_attach = on_attach
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
-- Configure volar (vuejs language server stuff) in "takeover" mode
|
-- Configure volar (vuejs language server stuff) in "takeover" mode
|
||||||
require'lspconfig'.volar.setup{
|
require'lspconfig'.volar.setup{
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'},
|
filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'},
|
||||||
on_attach = on_attach
|
|
||||||
}
|
}
|
||||||
--[[ If we didn't have takeover mode enabled above, we'd want this
|
--[[ If we didn't have takeover mode enabled above, we'd want this
|
||||||
require'lspconfig'.tsserver.setup{
|
require'lspconfig'.tsserver.setup{
|
||||||
|
|
Loading…
Reference in New Issue