Skip to content

Commit

Permalink
nvim:add is_lsp_running function and fix some issue
Browse files Browse the repository at this point in the history
Signed-off-by: tracyone <[email protected]>
  • Loading branch information
tracyone committed Dec 16, 2021
1 parent b78ea74 commit b76cd9a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions autoload/te/lsp.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
"lsp function wrapper

function! te#lsp#is_server_running() abort
if te#env#IsNvim() >= 0.5
return v:lua.require('utils').is_lsp_running()
endif
return 0
endfunction

function! te#lsp#gotodefinion() abort
if exists(':LspDefinition') == 2
:LspDefinition
Expand Down
14 changes: 14 additions & 0 deletions lua/utils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module = {}

local function get_size(tabl)
local size = 0
for _ in pairs(tabl) do size = size + 1 end
return size
end

function module.is_lsp_running()
local client_obj = vim.lsp.buf_get_clients()
return get_size(client_obj)
end

return module
14 changes: 7 additions & 7 deletions rc/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ function! s:enable_nvim_lsp()
lua << EOF
require('nvim_cmp')
EOF
autocmd FileType markdown,gitcommit require'cmp'.setup.buffer {
\ sources = {
\ {name='look', keyword_length=2},
\ { name = 'ultisnips' },
\ { name = 'buffer' },
\ },
\ }
autocmd FileType markdown,gitcommit,gina-commit lua require'cmp'.setup.buffer {
\ sources = {
\ {name='look', keyword_length=2},
\ { name = 'ultisnips' },
\ { name = 'buffer' },
\ },
\ }
endfunction
"Important config neovim lsp and cmp when vim enter
call te#feat#register_vim_enter_setting(function('<SID>enable_nvim_lsp'))
Expand Down

0 comments on commit b76cd9a

Please sign in to comment.