lazy plugin loading and autocmd to load the plugin

neovim_0_5
ray-x 3 years ago
parent 40c2144b98
commit 14886706db

@ -4,13 +4,14 @@ Easy code navigation through LSP and 🌲🏡Treesitter symbols, diagnostic erro
# Features:
- LSP easy setup. Support some of the most commonly used lsp client setup
- LSP easy setup. Support some of the most commonly used lsp client setup. Smart loading lsp clients based on buffer type.
- Out of box experience. 10 lines of minimum vimrc can turn your neovim into a full-featured LSP powered IDE
- Unorthodox UI with floating windows
- Async request with lsp.buf_request for reference search
- Treesitter symbol search. It is handy for large file (Do you know some of LSP e.g. sumneko_lua, there is a 100kb limition?)
- Treesitter symbol search. It is handy for large filas (Some of LSP e.g. sumneko_lua, there is a 100kb file size limition?)
- fzy search with Lua-JIT
- Better navigation for diagnostic errors, Navigate through files that contain errors/warnings
- Group references/implementation/incomming/outgoing based on file names.
- Better navigation for diagnostic errors, Navigate through all files/buffers that contain errors/warnings
- Grouping references/implementation/incomming/outgoing based on file names.
- Nerdfont, emoji for LSP and Treesitter kind
# Why a new plugin
@ -54,7 +55,7 @@ Easy setup **BOTH** lspconfig and navigator with one liner. Navigator covers aro
lua require'navigator'.setup()
```
## Sample vimrc
## Sample vimrc turning your neovim into a full-featured IDE
```vim
call plug#begin('~/.vim/plugged')
@ -63,19 +64,22 @@ Plug 'neovim/nvim-lspconfig'
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
Plug 'ray-x/navigator.lua'
" optional if you need treesitter symbol support
" Plug 'hrsh7th/nvim-compe' and other plugins you commenly use...
" optional, if you need treesitter symbol support
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
call plug#end()
" No need for rquire('lspconfig'), navigator will configure it for you
lua <<EOF
local nvim_lsp = require('lspconfig')
require'navigator'.setup()
EOF
```
Generally speaking, you could remove most part of your lspconfig.lua and use the hooks in navigator.lua
Generally speaking, you could remove most part of your lspconfig.lua and use the hooks in navigator.lua. As the
navigator will bind keys and handler for you. The lsp will be loaded lazily based on filetype.
## Dependency
@ -83,8 +87,7 @@ Generally speaking, you could remove most part of your lspconfig.lua and use the
- guihua.lua (provides floating window, FZY)
- Optional:
- treesitter (list treesitter symbols)
- lsp-signature
- vim-illuminate
- lsp-signature (better signature help)
The plugin can be loaded lazily (packer `opt = true` ), And it will check if optional plugins existance and load those plugins only if they existed.
@ -181,5 +184,5 @@ Improved signature help with current parameter highlighted
- Early phase, bugs expected, PR and suggestions are welcome
- Async (some of the requests is slow on large codebases and might be good to use co-rountine)
- More clients. I use go, python, js/ts, java, c/cpp, lua most of the time. Do not test other languages (e.g dart, swift etc)
- More clients. I use go, python, js/ts, java, c/cpp, lua most of the time. Did not test other languages (e.g dart, swift etc)
- Configuration options

@ -22,6 +22,7 @@ _NgConfigValues ={
vim.cmd("command! -nargs=0 LspLog call v:lua.open_lsp_log()")
vim.cmd("command! -nargs=0 LspRestart call v:lua.reload_lsp()")
vim.cmd([[autocmd filetype * lua require'navigator'.setup()]]) -- BufWinEnter BufNewFile,BufRead ?
local extend_config = function(opts)
opts = opts or {}
@ -56,7 +57,8 @@ M.setup = function(cfg)
if _NgConfigValues.code_action_prompt.enable then
vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'navigator.codeAction'.code_action_prompt()]]
end
-- vim.cmd("autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4")
end
return M

@ -88,7 +88,7 @@ local clang_cfg = {
}
local rust_cfg = {
root_dir = util.root_pattern("Cargo.toml", "rust-project.json", ".git"),
filetypes = { "rust" },
filetypes = {"rust"},
message_level = vim.lsp.protocol.MessageType.error,
on_attach = on_attach,
settings = {
@ -204,13 +204,14 @@ local servers = {
}
local default_cfg = {on_attach = on_attach}
-- check and load based on file type
local function load_cfg(client, cfg)
local ft = vim.bo.filetype
if ft == nil then
ft = vim.api.nvim_buf_get_option(0,'filetype')
ft = vim.api.nvim_buf_get_option(0, "filetype")
end
if ft == nil or ft == '' then
log('nil filetype')
if ft == nil or ft == "" then
log("nil filetype")
return
end
-- log(client, "loaded for", ft)
@ -252,9 +253,7 @@ local function setup(user_opts)
load_cfg("sqls", sqls_cfg)
load_cfg("sumneko_lua", lua_cfg)
load_cfg("clangd", clang_cfg)
-- load_cfg("rust_analyzer", rust_cfg)
load_cfg("rust_analyzer", rust_cfg)
load_cfg("pyright", pyright_cfg)
lspconfig.rust_analyzer.setup(rust_cfg)
log("setup all clients finished")
end
return {setup = setup, cap = cap}

@ -161,7 +161,6 @@ function M.setup(user_opts)
vim.lsp.handlers["textDocument/signatureHelp"] = require "navigator.signature".signature_handler
end
-- vim.lsp.handlers["textDocument/hover"] = require 'navigator.hover'.hover_handler
end
return M

Loading…
Cancel
Save