|
@@ -1,36 +1,40 @@
|
|
|
---Set highlight on search
|
|
|
-vim.o.hlsearch = false
|
|
|
-
|
|
|
---Set statusbar
|
|
|
-vim.g.lightline = {
|
|
|
- colorscheme = 'onedark',
|
|
|
- active = { left = { { 'mode', 'paste' }, { 'gitbranch', 'readonly', 'filename', 'modified' } } },
|
|
|
- component_function = { gitbranch = 'fugitive#head' },
|
|
|
-}
|
|
|
-
|
|
|
--- Highlight on yank
|
|
|
-vim.api.nvim_exec(
|
|
|
-[[
|
|
|
- augroup YankHighlight
|
|
|
- autocmd!
|
|
|
- autocmd TextYankPost * silent! lua vim.highlight.on_yank()
|
|
|
- augroup end
|
|
|
-]],
|
|
|
-false
|
|
|
-)
|
|
|
-
|
|
|
-local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
|
+local lsp = require('lsp-zero')
|
|
|
+lsp.preset('recommended')
|
|
|
+
|
|
|
+lsp.ensure_installed({
|
|
|
+ 'tsserver',
|
|
|
+ 'eslint',
|
|
|
+ 'sumneko_lua',
|
|
|
+ 'gopls',
|
|
|
+ 'rust_analyzer',
|
|
|
+ 'clangd',
|
|
|
+ 'jedi_language_server'
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+-- Fix Undefined global 'vim'
|
|
|
+lsp.configure('sumneko_lua', {
|
|
|
+ settings = {
|
|
|
+ Lua = {
|
|
|
+ diagnostics = {
|
|
|
+ globals = { 'vim' }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
local cmp = require'cmp'
|
|
|
+local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
|
|
|
|
|
cmp.setup({
|
|
|
mapping = {
|
|
|
["<C-e>"] = cmp.mapping.close(),
|
|
|
- ["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
|
- ["<C-n>"] = cmp.mapping.select_next_item(),
|
|
|
+ ["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
|
|
|
+ ["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
|
["<C-y>"] = cmp.mapping.confirm {
|
|
|
- behavior = cmp.ConfirmBehavior.Insert,
|
|
|
select = true,
|
|
|
},
|
|
|
["<C-space>"] = cmp.mapping.complete(),
|
|
@@ -47,9 +51,9 @@ cmp.setup({
|
|
|
},
|
|
|
|
|
|
snippet = {
|
|
|
- expand = function(args)
|
|
|
+ expand = function(args)
|
|
|
require('luasnip').lsp_expand(args.body)
|
|
|
- end,
|
|
|
+ end,
|
|
|
},
|
|
|
|
|
|
experimental = {
|
|
@@ -57,15 +61,11 @@ cmp.setup({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
-vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
|
|
-vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
|
|
-vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
|
|
-vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
|
|
|
|
|
-local on_attach = function(client, bufnr)
|
|
|
- -- Enable completion triggered by <c-x><c-o>
|
|
|
- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
+lsp.on_attach(function(client, bufnr)
|
|
|
+ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
|
|
-- Mappings.
|
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
@@ -82,16 +82,12 @@ local on_attach = function(client, bufnr)
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
|
|
-end
|
|
|
+
|
|
|
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
|
|
+
|
|
|
+end)
|
|
|
+
|
|
|
+
|
|
|
+lsp.setup()
|
|
|
|
|
|
|
|
|
-local servers = { 'gopls', 'clangd', 'jedi_language_server' , 'rust_analyzer', 'tsserver' }
|
|
|
-for _, lsp in pairs(servers) do
|
|
|
- require('lspconfig')[lsp].setup {
|
|
|
- on_attach = on_attach,
|
|
|
- flags = {
|
|
|
- -- This will be the default in neovim 0.7+
|
|
|
- debounce_text_changes = 150,
|
|
|
- }
|
|
|
- }
|
|
|
-end
|