try switch to lsp-zero for nvim
This commit is contained in:
+36
-28
@@ -24,11 +24,6 @@
|
|||||||
|
|
||||||
call plug#begin(plugin_dir)
|
call plug#begin(plugin_dir)
|
||||||
|
|
||||||
" make sure to install nodejs to use coc.nvim
|
|
||||||
if executable('node')
|
|
||||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
||||||
endif
|
|
||||||
|
|
||||||
Plug 'rust-lang/rust.vim'
|
Plug 'rust-lang/rust.vim'
|
||||||
|
|
||||||
" {
|
" {
|
||||||
@@ -62,11 +57,14 @@
|
|||||||
Plug 'NLKNguyen/papercolor-theme'
|
Plug 'NLKNguyen/papercolor-theme'
|
||||||
Plug 'airblade/vim-rooter'
|
Plug 'airblade/vim-rooter'
|
||||||
Plug 'mbbill/undotree'
|
Plug 'mbbill/undotree'
|
||||||
|
|
||||||
|
" Comment stuff out
|
||||||
Plug 'tpope/vim-commentary'
|
Plug 'tpope/vim-commentary'
|
||||||
|
|
||||||
" put text in neibouring tmux pane into auto complete
|
" put text in neibouring tmux pane into auto complete
|
||||||
Plug 'wellle/tmux-complete.vim'
|
Plug 'wellle/tmux-complete.vim'
|
||||||
Plug 'NoahTheDuke/vim-just'
|
|
||||||
|
"Plug 'NoahTheDuke/vim-just'
|
||||||
|
|
||||||
Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp', 'vim'] }
|
Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp', 'vim'] }
|
||||||
Plug 'lambdalisue/readablefold.vim'
|
Plug 'lambdalisue/readablefold.vim'
|
||||||
@@ -81,7 +79,12 @@
|
|||||||
" The bottom buffer display
|
" The bottom buffer display
|
||||||
Plug 'Donaldttt/vim-bufferline'
|
Plug 'Donaldttt/vim-bufferline'
|
||||||
Plug 'ryanoasis/vim-devicons'
|
Plug 'ryanoasis/vim-devicons'
|
||||||
" Plug 'itchyny/lightline.vim'
|
if executable('node')
|
||||||
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||||
|
endif
|
||||||
|
if executable('fzf')
|
||||||
|
Plug 'antoinemadec/coc-fzf'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" only work with nvim > 0.5
|
" only work with nvim > 0.5
|
||||||
@@ -97,6 +100,28 @@
|
|||||||
|
|
||||||
Plug 'nvim-lualine/lualine.nvim'
|
Plug 'nvim-lualine/lualine.nvim'
|
||||||
|
|
||||||
|
"{ lsp-zero
|
||||||
|
|
||||||
|
" LSP Support
|
||||||
|
Plug 'neovim/nvim-lspconfig' " Required
|
||||||
|
Plug 'williamboman/mason.nvim' " Optional
|
||||||
|
Plug 'williamboman/mason-lspconfig.nvim' " Optional
|
||||||
|
|
||||||
|
" Autocompletion Engine
|
||||||
|
Plug 'hrsh7th/nvim-cmp' " Required
|
||||||
|
Plug 'hrsh7th/cmp-nvim-lsp' " Required
|
||||||
|
Plug 'hrsh7th/cmp-buffer' " Optional
|
||||||
|
Plug 'hrsh7th/cmp-path' " Optional
|
||||||
|
Plug 'saadparwaiz1/cmp_luasnip' " Optional
|
||||||
|
Plug 'hrsh7th/cmp-nvim-lua' " Optional
|
||||||
|
|
||||||
|
" Snippets
|
||||||
|
Plug 'L3MON4D3/LuaSnip' " Required
|
||||||
|
Plug 'rafamadriz/friendly-snippets' " Optional
|
||||||
|
|
||||||
|
Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v1.x'}
|
||||||
|
"}
|
||||||
|
|
||||||
endif
|
endif
|
||||||
if g:vim_version >= 0.7
|
if g:vim_version >= 0.7
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
@@ -259,22 +284,6 @@ endif
|
|||||||
" }
|
" }
|
||||||
"else
|
"else
|
||||||
"
|
"
|
||||||
" itchyny/lightline.vim {
|
|
||||||
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/lightline.vim"))
|
|
||||||
set laststatus=2
|
|
||||||
let g:lightline = {
|
|
||||||
\ 'colorscheme': 'wombat',
|
|
||||||
\ 'active': {
|
|
||||||
\ 'left': [ [ 'mode', 'paste' ],
|
|
||||||
\ [ 'buffers' ] ]
|
|
||||||
\ },
|
|
||||||
\ 'component_function': {
|
|
||||||
\ 'buffers': 'bufferline#get_echo_string'
|
|
||||||
\ },
|
|
||||||
\ }
|
|
||||||
endif
|
|
||||||
" }
|
|
||||||
"
|
|
||||||
" vim-airline {
|
" vim-airline {
|
||||||
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/vim-airline"))
|
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/vim-airline"))
|
||||||
" Set configuration options for the statusline plugin vim-airline.
|
" Set configuration options for the statusline plugin vim-airline.
|
||||||
@@ -348,7 +357,7 @@ endif
|
|||||||
" }
|
" }
|
||||||
|
|
||||||
" neoclide/coc.nvim {
|
" neoclide/coc.nvim {
|
||||||
if isdirectory(expand(plugin_dir . "/coc.nvim/")) && executable('node')
|
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/coc.nvim/")) && executable('node')
|
||||||
" add desired extensions to the following global variable
|
" add desired extensions to the following global variable
|
||||||
" coc-tsserver: javascript
|
" coc-tsserver: javascript
|
||||||
" coc-pyright: python
|
" coc-pyright: python
|
||||||
@@ -494,6 +503,7 @@ endif
|
|||||||
execute("colorscheme " . g:light_theme)
|
execute("colorscheme " . g:light_theme)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
call TransparentBackgroundFix()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! DisableTransparent()
|
function! DisableTransparent()
|
||||||
@@ -555,7 +565,6 @@ endif
|
|||||||
call CreateSignalFile('.transparent_light_theme.signal')
|
call CreateSignalFile('.transparent_light_theme.signal')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call TransparentBackgroundFix()
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@@ -593,12 +602,13 @@ endif
|
|||||||
|
|
||||||
" Since in .vimrc we cannot call plugin function as they
|
" Since in .vimrc we cannot call plugin function as they
|
||||||
" are not loaded (:help startup)
|
" are not loaded (:help startup)
|
||||||
if g:transparent_dark_theme && g:dark_or_white_theme == 'dark' || g:transparent_light_theme && g:dark_or_white_theme == 'light'
|
if (g:transparent_dark_theme && g:dark_or_white_theme == 'dark') || (g:transparent_light_theme && g:dark_or_white_theme == 'light')
|
||||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||||
let g:transparent_enabled = v:true
|
let g:transparent_enabled = v:true
|
||||||
else
|
else
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
endif
|
endif
|
||||||
|
call TransparentBackgroundFix()
|
||||||
else
|
else
|
||||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||||
let g:transparent_enabled = v:false
|
let g:transparent_enabled = v:false
|
||||||
@@ -607,7 +617,6 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call TransparentBackgroundFix()
|
|
||||||
" Allow to trigger background
|
" Allow to trigger background
|
||||||
function! ToggleBG()
|
function! ToggleBG()
|
||||||
" Inversion
|
" Inversion
|
||||||
@@ -627,7 +636,6 @@ endif
|
|||||||
else
|
else
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
endif
|
endif
|
||||||
call TransparentBackgroundFix()
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }
|
" }
|
||||||
|
|||||||
+80
-27
@@ -1,11 +1,10 @@
|
|||||||
vim_version = vim.version()
|
local vim_version = vim.version()
|
||||||
vim_version_minor = vim_version['minor']
|
local vim_version_minor = vim_version['minor']
|
||||||
|
|
||||||
-- debug
|
-- debug
|
||||||
-- print(vim.inspect(version))
|
-- print(vim.inspect(version))
|
||||||
|
|
||||||
if vim_version_minor >= 5 then
|
local function transparent_config()
|
||||||
|
|
||||||
require("transparent").setup({
|
require("transparent").setup({
|
||||||
enable = true, -- boolean: enable transparent
|
enable = true, -- boolean: enable transparent
|
||||||
extra_groups = { -- table/string: additional groups that should be cleared
|
extra_groups = { -- table/string: additional groups that should be cleared
|
||||||
@@ -16,26 +15,63 @@ if vim_version_minor >= 5 then
|
|||||||
},
|
},
|
||||||
exclude = {}, -- table: groups you don't want to clear
|
exclude = {}, -- table: groups you don't want to clear
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim_version_minor >= 7 then
|
local function lsp_zero_config()
|
||||||
|
-- Learn the keybindings, see :help lsp-zero-keybindings
|
||||||
|
-- Learn to configure LSP servers, see :help lsp-zero-api-showcase
|
||||||
|
local lsp = require('lsp-zero')
|
||||||
|
lsp.preset('recommended')
|
||||||
|
-- make sure this servers are installed
|
||||||
|
-- see :help lsp-zero.ensure_installed()
|
||||||
|
lsp.ensure_installed({
|
||||||
|
'rust_analyzer',
|
||||||
|
'tsserver',
|
||||||
|
'eslint',
|
||||||
|
'sumneko_lua',
|
||||||
|
'jdtls',
|
||||||
|
'vimls',
|
||||||
|
})
|
||||||
|
-- local cmp = require('cmp')
|
||||||
|
|
||||||
require('nvim-treesitter.configs').setup {
|
-- lsp.setup_nvim_cmp({
|
||||||
-- ensure_installed = { "c", "bash", "lua" },
|
-- mapping = cmp.mapping.preset.insert({
|
||||||
sync_install = false,
|
-- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
auto_install = true,
|
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
-- ignore_install = { "javascript" },
|
-- })
|
||||||
highlight = {
|
-- })
|
||||||
enable = true,
|
|
||||||
additional_vim_regex_highlighting = false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
-- vim.api.nvim_create_autocmd(
|
||||||
|
-- {"TextChangedI", "TextChangedP"},
|
||||||
|
-- {
|
||||||
|
-- callback = function()
|
||||||
|
-- local line = vim.api.nvim_get_current_line()
|
||||||
|
-- local cursor = vim.api.nvim_win_get_cursor(0)[2]
|
||||||
|
|
||||||
|
-- local current = string.sub(line, cursor, cursor + 1)
|
||||||
|
-- if current == "." or current == "," or current == " " then
|
||||||
|
-- require('cmp').close()
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- local before_line = string.sub(line, 1, cursor + 1)
|
||||||
|
-- local after_line = string.sub(line, cursor + 1, -1)
|
||||||
|
-- if not string.match(before_line, '^%s+$') then
|
||||||
|
-- if after_line == "" or string.match(before_line, " $") or string.match(before_line, "%.$") then
|
||||||
|
-- require('cmp').complete()
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
|
-- pattern = "*"
|
||||||
|
-- }
|
||||||
|
-- )
|
||||||
|
|
||||||
|
-- (Optional) Configure lua language server for neovim
|
||||||
|
lsp.nvim_workspace()
|
||||||
|
|
||||||
|
lsp.setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim_version_minor >= 5 then
|
local function lualine_config()
|
||||||
|
|
||||||
for i=1,9 do
|
for i=1,9 do
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>'..i, ':LualineBuffersJump '..i..'<CR>', { noremap = true, silent = true, nowait = true })
|
vim.api.nvim_set_keymap('n', '<Leader>'..i, ':LualineBuffersJump '..i..'<CR>', { noremap = true, silent = true, nowait = true })
|
||||||
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
|
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
|
||||||
@@ -54,7 +90,6 @@ if vim_version_minor >= 5 then
|
|||||||
'NvimTree'
|
'NvimTree'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
require('lualine').setup {
|
require('lualine').setup {
|
||||||
options = {
|
options = {
|
||||||
theme = 'auto', -- lualine theme
|
theme = 'auto', -- lualine theme
|
||||||
@@ -96,13 +131,22 @@ if vim_version_minor >= 5 then
|
|||||||
lualine_z = {'encoding', 'location'}
|
lualine_z = {'encoding', 'location'}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim_version_minor >= 8 then
|
local function nvim_treesitter_config()
|
||||||
-- nvim-tree configuration
|
require('nvim-treesitter.configs').setup {
|
||||||
--
|
-- ensure_installed = { "c", "bash", "lua" },
|
||||||
|
sync_install = false,
|
||||||
|
auto_install = true,
|
||||||
|
-- ignore_install = { "javascript" },
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function nvim_tree_config()
|
||||||
-- disable netrw at the very start of your init.lua (strongly advised)
|
-- disable netrw at the very start of your init.lua (strongly advised)
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
@@ -144,8 +188,17 @@ if vim_version_minor >= 8 then
|
|||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
|
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
|
||||||
|
|
||||||
--
|
|
||||||
-- nvim-tree configuration end
|
|
||||||
--
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if vim_version_minor >= 5 then
|
||||||
|
transparent_config()
|
||||||
|
lsp_zero_config()
|
||||||
|
lualine_config()
|
||||||
|
end
|
||||||
|
if vim_version_minor >= 7 then
|
||||||
|
nvim_treesitter_config()
|
||||||
|
end
|
||||||
|
if vim_version_minor >= 8 then
|
||||||
|
nvim_tree_config()
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -17,16 +17,16 @@ nmap <silent> gy <Plug>(coc-type-definition)
|
|||||||
nmap <silent> gi <Plug>(coc-implementation)
|
nmap <silent> gi <Plug>(coc-implementation)
|
||||||
nmap <silent> gr <Plug>(coc-references)
|
nmap <silent> gr <Plug>(coc-references)
|
||||||
|
|
||||||
" " Use K to show documentation in preview window.
|
" Use K to show documentation in preview window.
|
||||||
" nnoremap <silent> K :call <SID>show_documentation()<CR>
|
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||||
|
|
||||||
" function! s:show_documentation()
|
function! s:show_documentation()
|
||||||
" if CocAction('hasProvider', 'hover')
|
if CocAction('hasProvider', 'hover')
|
||||||
" call CocActionAsync('doHover')
|
call CocActionAsync('doHover')
|
||||||
" else
|
else
|
||||||
" call feedkeys('K', 'in')
|
call feedkeys('K', 'in')
|
||||||
" endif
|
endif
|
||||||
" endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Symbol renaming.
|
" Symbol renaming.
|
||||||
|
|||||||
Reference in New Issue
Block a user