try switch to lsp-zero for nvim

This commit is contained in:
Nachuan Tang
2023-02-07 21:39:41 -05:00
parent 828f3e0c29
commit 9338b7a9dc
3 changed files with 127 additions and 66 deletions
+37 -29
View File
@@ -24,11 +24,6 @@
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'
" {
@@ -62,11 +57,14 @@
Plug 'NLKNguyen/papercolor-theme'
Plug 'airblade/vim-rooter'
Plug 'mbbill/undotree'
Plug 'tpope/vim-commentary'
" Comment stuff out
Plug 'tpope/vim-commentary'
" put text in neibouring tmux pane into auto complete
Plug 'wellle/tmux-complete.vim'
Plug 'NoahTheDuke/vim-just'
"Plug 'NoahTheDuke/vim-just'
Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp', 'vim'] }
Plug 'lambdalisue/readablefold.vim'
@@ -81,7 +79,12 @@
" The bottom buffer display
Plug 'Donaldttt/vim-bufferline'
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
" only work with nvim > 0.5
@@ -97,6 +100,28 @@
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
if g:vim_version >= 0.7
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
@@ -259,22 +284,6 @@ endif
" }
"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 {
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/vim-airline"))
" Set configuration options for the statusline plugin vim-airline.
@@ -348,7 +357,7 @@ endif
" }
" 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
" coc-tsserver: javascript
" coc-pyright: python
@@ -494,6 +503,7 @@ endif
execute("colorscheme " . g:light_theme)
endif
endif
call TransparentBackgroundFix()
endfunction
function! DisableTransparent()
@@ -555,7 +565,6 @@ endif
call CreateSignalFile('.transparent_light_theme.signal')
endif
endif
call TransparentBackgroundFix()
endfunction
@@ -593,12 +602,13 @@ endif
" Since in .vimrc we cannot call plugin function as they
" 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
let g:transparent_enabled = v:true
else
call EnableTransparent()
endif
call TransparentBackgroundFix()
else
if g:vim_type == 'nvim' && g:vim_version > 0.5
let g:transparent_enabled = v:false
@@ -607,7 +617,6 @@ endif
endif
endif
call TransparentBackgroundFix()
" Allow to trigger background
function! ToggleBG()
" Inversion
@@ -627,7 +636,6 @@ endif
else
call DisableTransparent()
endif
call TransparentBackgroundFix()
endfunction
" }
+81 -28
View File
@@ -1,11 +1,10 @@
vim_version = vim.version()
vim_version_minor = vim_version['minor']
local vim_version = vim.version()
local vim_version_minor = vim_version['minor']
-- debug
-- print(vim.inspect(version))
if vim_version_minor >= 5 then
local function transparent_config()
require("transparent").setup({
enable = true, -- boolean: enable transparent
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
})
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 {
-- ensure_installed = { "c", "bash", "lua" },
sync_install = false,
auto_install = true,
-- ignore_install = { "javascript" },
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
-- lsp.setup_nvim_cmp({
-- mapping = cmp.mapping.preset.insert({
-- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- })
-- })
-- 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
if vim_version_minor >= 5 then
local function lualine_config()
for i=1,9 do
vim.api.nvim_set_keymap('n', '<Leader>'..i, ':LualineBuffersJump '..i..'<CR>', { noremap = true, silent = true, nowait = true })
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
@@ -54,7 +90,6 @@ if vim_version_minor >= 5 then
'NvimTree'
}
end
require('lualine').setup {
options = {
theme = 'auto', -- lualine theme
@@ -68,7 +103,7 @@ if vim_version_minor >= 5 then
sections = {
lualine_a = {'mode'},
lualine_b = {},
lualine_c = {
lualine_c = {
{
'buffers',
mode = 2,
@@ -96,13 +131,22 @@ if vim_version_minor >= 5 then
lualine_z = {'encoding', 'location'}
},
}
end
if vim_version_minor >= 8 then
-- nvim-tree configuration
--
local function nvim_treesitter_config()
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)
vim.g.loaded_netrw = 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 })
--
-- nvim-tree configuration 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
View File
@@ -17,16 +17,16 @@ nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" " Use K to show documentation in preview window.
" nnoremap <silent> K :call <SID>show_documentation()<CR>
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
" function! s:show_documentation()
" if CocAction('hasProvider', 'hover')
" call CocActionAsync('doHover')
" else
" call feedkeys('K', 'in')
" endif
" endfunction
function! s:show_documentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Symbol renaming.