From b928bcc39bb3767d4fa04803265d10ff507b82cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B0=B8=E6=98=A5?= Date: Fri, 19 Dec 2025 13:14:54 +0800 Subject: [PATCH] statusbar and lsp --- layers/plug/init.vim | 7 +++++-- layers/plug/lsp.vim | 34 ++++++++++++++++++++++++++++++++++ layers/plug/nerdtree.vim | 7 ++++++- layers/plug/qline.vim | 8 ++++++++ layers/plug/whichkey.vim | 3 +-- 5 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 layers/plug/lsp.vim create mode 100644 layers/plug/qline.vim diff --git a/layers/plug/init.vim b/layers/plug/init.vim index cc37fea..7e989f9 100644 --- a/layers/plug/init.vim +++ b/layers/plug/init.vim @@ -2,10 +2,13 @@ vim9script TuiLayer plug.colorscheme +TuiLayer plug.whichkey + TuiLayer plug.nerdtree TuiLayer plug.poplar -TuiLayer plug.whichkey +TuiLayer plug.qline + +TuiLayer plug.lsp -TuiLayer plug.coc diff --git a/layers/plug/lsp.vim b/layers/plug/lsp.vim new file mode 100644 index 0000000..4ae01f8 --- /dev/null +++ b/layers/plug/lsp.vim @@ -0,0 +1,34 @@ +vim9script + +# lsp servers +g:lsp_servers = [] +## clangd +const clangd_path = has('win32') || has('win64') ? expand('$SCOOP/apps/clangd/current/bin/clangd.exe') : '/usr/bin/clangd' +if filereadable(clangd_path) + add(g:lsp_servers, { name: 'clangd', filetype: ['c', 'cpp', 'h'], path: clangd_path, args: ['--background-index'] }) +endif +## vimlsp +const vimlsp_path = expand("$HOME/.vmr/versions/node_versions/node/bin/vim-language-server") +if filereadable(vimlsp_path) + add(g:lsp_servers, { name: 'vimlsp', filetype: ['vim', 'vimrc'], path: vimlsp_path, args: ['--stdio'] }) +endif + +# lsp options +g:lsp_options = { + autoHighligntDiags: v:true +} + +tui#core#plug#Regist('yegappan/lsp', { + config: () => { + autocmd User LspSetup call LspOptionsSet(g:lsp_options) + autocmd User LspSetup call LspAddServer(g:lsp_servers) + # keymaps + nnoremap K :LspHover + if exists('g:which_key_map') + g:which_key_map['v']['o'] = ['LspOutline', 'outline'] + else + nnoremap vo :LspOutline + endif + } +}) + diff --git a/layers/plug/nerdtree.vim b/layers/plug/nerdtree.vim index 4bf83aa..a50d321 100644 --- a/layers/plug/nerdtree.vim +++ b/layers/plug/nerdtree.vim @@ -7,7 +7,12 @@ tui#core#plug#Regist('preservim/nerdtree', { ], config: () => { final g:NERDTreeFileLines = 1 - nnoremap vf :NERDTreeToggle + if exists('g:which_key_map') + g:which_key_map['v']['f'] = ['NERDTreeToggle', 'nerdtree'] + else + nnoremap vf :NERDTreeToggle + endif + } }) diff --git a/layers/plug/qline.vim b/layers/plug/qline.vim new file mode 100644 index 0000000..892ef44 --- /dev/null +++ b/layers/plug/qline.vim @@ -0,0 +1,8 @@ +vim9script + +g:qline_config = { + separator: { left: "\ue0b0", right: "\ue0b2", margin: ' ' }, + subseparator: { left: "\ue0b1", right: "\ue0b3", margin: ' ' }, +} + +tui#core#plug#Regist('Bakudankun/qline.vim') diff --git a/layers/plug/whichkey.vim b/layers/plug/whichkey.vim index ef4100d..1d6013c 100644 --- a/layers/plug/whichkey.vim +++ b/layers/plug/whichkey.vim @@ -1,6 +1,6 @@ vim9script -const g:which_key_map = { +g:which_key_map = { f: { name: 'File', o: ['Poplar', 'open'], @@ -8,7 +8,6 @@ const g:which_key_map = { }, v: { name: 'View', - f: ["NERDTreeToggle", "nerdtree"] } }