2021-04-19 02:56:32 +00:00
|
|
|
# Navigator
|
|
|
|
|
2021-04-25 10:34:33 +00:00
|
|
|
Easy code navigation through LSP and 🌲🏡Treesitter symbols, diagnostic errors.
|
2021-04-19 02:56:32 +00:00
|
|
|
|
|
|
|
# Features:
|
|
|
|
|
|
|
|
- LSP easy setup. Support some of the most commonly used lsp client setup
|
2021-04-24 04:58:19 +00:00
|
|
|
- Unorthodox UI with floating windows
|
2021-04-26 11:45:45 +00:00
|
|
|
- Async request with lsp.buf_request for reference search
|
2021-04-26 13:40:20 +00:00
|
|
|
- Treesitter symbol search. It is handy for large file (Do you know some of LSP e.g. sumneko_lua, there is a 100kb limition?)
|
2021-04-20 07:42:03 +00:00
|
|
|
- fzy search with Lua-JIT
|
2021-04-19 02:56:32 +00:00
|
|
|
- Better navigation for diagnostic errors, Navigate through files that contain errors/warnings
|
|
|
|
- Group references/implementation/incomming/outgoing based on file names.
|
2021-04-24 04:20:42 +00:00
|
|
|
- Nerdfont, emoji for LSP and Treesitter kind
|
2021-04-19 02:56:32 +00:00
|
|
|
|
|
|
|
# Why a new plugin
|
|
|
|
|
2021-04-24 04:58:19 +00:00
|
|
|
After installed a handful of lsp plugins, I still got ~800 loc for lsp and treesitter and still increasing because I need
|
|
|
|
to tune the lsp plugins to fit my requirements. Navigator.lua help user setup lspconfig with only a few lines of codes.
|
|
|
|
This plugin provide a visual way to manage and navigate through symobls, errors etc.
|
2021-04-24 02:38:47 +00:00
|
|
|
It also the first plugin, IMO, that allows you to search in all treesitter symbols in the workspace.
|
2021-04-19 02:56:32 +00:00
|
|
|
|
|
|
|
# Similar projects / special mentions:
|
|
|
|
|
|
|
|
- [nvim-lsputils](https://github.com/RishabhRD/nvim-lsputils)
|
|
|
|
- [nvim-fzy](https://github.com/mfussenegger/nvim-fzy.git)
|
|
|
|
- [fuzzy](https://github.com/amirrezaask/fuzzy.nvim)
|
|
|
|
- [lspsaga](https://github.com/glepnir/lspsaga.nvim)
|
2021-04-20 07:42:03 +00:00
|
|
|
- [fzf-lsp lsp with fzf as gui backend](https://github.com/gfanto/fzf-lsp.nvim)
|
2021-04-19 02:56:32 +00:00
|
|
|
|
|
|
|
# Install
|
|
|
|
|
|
|
|
You can remove your lspconfig setup and use this plugin.
|
2021-04-21 01:58:15 +00:00
|
|
|
The plugin depends on [guihua.lua](https://github.com/ray-x/guihua.lua), which provides GUI and fzy support.
|
2021-04-19 02:56:32 +00:00
|
|
|
|
|
|
|
```vim
|
|
|
|
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
|
|
|
|
Plug 'ray-x/navigator.lua'
|
|
|
|
```
|
|
|
|
|
|
|
|
Packer
|
|
|
|
|
|
|
|
```lua
|
|
|
|
|
|
|
|
use {'ray-x/navigator.lua', requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
|
|
|
```lua
|
|
|
|
lua require'navigator'.setup()
|
|
|
|
```
|
|
|
|
|
2021-04-24 10:30:31 +00:00
|
|
|
## Sample vimrc
|
|
|
|
|
|
|
|
```vim
|
|
|
|
call plug#begin('~/.vim/plugged')
|
|
|
|
|
|
|
|
Plug 'neovim/nvim-lspconfig'
|
|
|
|
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
|
|
|
|
Plug 'ray-x/navigator.lua'
|
|
|
|
|
2021-04-25 10:25:53 +00:00
|
|
|
" optional if you need treesitter symbol support
|
|
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
|
|
|
2021-04-24 10:30:31 +00:00
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-04-25 10:34:33 +00:00
|
|
|
## Dependency
|
2021-04-25 02:43:18 +00:00
|
|
|
|
|
|
|
- lspconfig
|
2021-04-25 10:34:33 +00:00
|
|
|
- guihua.lua (provides floating window, FZY)
|
2021-04-25 02:43:18 +00:00
|
|
|
- Optional:
|
2021-04-25 10:25:53 +00:00
|
|
|
- treesitter (list treesitter symbols)
|
2021-04-25 02:43:18 +00:00
|
|
|
- lsp-signature
|
|
|
|
- vim-illuminate
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2021-04-19 03:09:32 +00:00
|
|
|
## Usage
|
|
|
|
|
2021-04-24 10:30:31 +00:00
|
|
|
Please refer to lua/navigator/lspclient/mapping.lua on key mappings. Should be able to work out-of-box.
|
|
|
|
|
|
|
|
- Use \<c-e\> or `:q!` to kill the floating window
|
2021-04-25 03:58:32 +00:00
|
|
|
- <up/down> (or \<c-n\>, \<c-p\>) to move
|
2021-04-24 10:30:31 +00:00
|
|
|
- \<c-o\> to open location or apply code actions
|
2021-04-19 03:09:32 +00:00
|
|
|
|
2021-04-26 11:21:01 +00:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
In `navigator.lua` there is a default configration. You can override the values by pass you own values
|
|
|
|
|
|
|
|
e.g
|
|
|
|
|
|
|
|
```lua
|
|
|
|
-- The attach will be call at end of navigator on_attach()
|
|
|
|
require'navigator'.setup({on_attach = function(client, bufnr) require 'illuminate'.on_attach(client)})
|
|
|
|
```
|
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
## Screenshots
|
|
|
|
|
2021-04-25 10:34:33 +00:00
|
|
|
colorscheme: [aurora](https://github.com/ray-x/aurora)
|
2021-04-24 10:30:31 +00:00
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
### Reference
|
|
|
|
|
|
|
|
![reference](https://github.com/ray-x/files/blob/master/img/navigator/ref.gif?raw=true)
|
2021-04-20 22:25:31 +00:00
|
|
|
|
|
|
|
### Document Symbol
|
|
|
|
|
|
|
|
![document symbol](https://github.com/ray-x/files/blob/master/img/navigator/doc_symbol.gif?raw=true)
|
2021-04-19 02:56:32 +00:00
|
|
|
|
2021-04-23 08:19:59 +00:00
|
|
|
### Workspace Symbol
|
|
|
|
|
|
|
|
![workspace symbol](https://github.com/ray-x/files/blob/master/img/navigator/workspace_symbol.gif?raw=true)
|
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
### Diagnostic
|
|
|
|
|
2021-04-25 10:34:33 +00:00
|
|
|
Diagnostic in single bufer
|
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
![diagnostic](https://github.com/ray-x/files/blob/master/img/navigator/diag.jpg?raw=true)
|
2021-04-25 10:34:33 +00:00
|
|
|
|
|
|
|
Show diagnostic in all buffers
|
|
|
|
|
2021-04-24 09:55:48 +00:00
|
|
|
![diagnostic multi files](https://github.com/ray-x/files/blob/master/img/navigator/diagnostic_multiplefiles.jpg?raw=true)
|
2021-04-19 02:56:32 +00:00
|
|
|
|
|
|
|
### Implementation
|
|
|
|
|
|
|
|
![implementation](https://github.com/ray-x/files/blob/master/img/navigator/implemention.jpg?raw=true)
|
|
|
|
|
|
|
|
### Fzy search in reference
|
|
|
|
|
|
|
|
![fzy_reference](https://github.com/ray-x/files/blob/master/img/navigator/fzy_reference.jpg?raw=true)
|
|
|
|
|
|
|
|
### Code actions
|
|
|
|
|
|
|
|
![code actions](https://github.com/ray-x/files/blob/master/img/navigator/codeaction.jpg?raw=true)
|
|
|
|
|
2021-04-24 10:30:31 +00:00
|
|
|
Fill struct with gopls
|
|
|
|
![code actions fill struct](https://github.com/ray-x/files/blob/master/img/navigator/fill_struct.gif?raw=true)
|
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
### Code preview with highlight
|
|
|
|
|
|
|
|
![code preview](https://github.com/ray-x/files/blob/master/img/navigator/preview_with_hl.jpg?raw=true)
|
|
|
|
|
2021-04-24 02:38:47 +00:00
|
|
|
### Treesitter symbol
|
|
|
|
|
|
|
|
Treetsitter symbols in all buffers
|
|
|
|
![treesitter](https://github.com/ray-x/files/blob/master/img/navigator/treesitter.jpg?raw=true)
|
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
### Call hierarchy (incomming/outgoing)
|
|
|
|
|
|
|
|
![incomming](https://github.com/ray-x/files/blob/master/img/navigator/incomming.jpg?raw=true)
|
|
|
|
|
2021-04-24 04:44:57 +00:00
|
|
|
### Light bulb when codeAction avalible
|
|
|
|
|
|
|
|
![lightbulb](https://github.com/ray-x/files/blob/master/img/navigator/lightbulb.jpg?raw=true)
|
|
|
|
|
|
|
|
### Predefined LSP symbol nerdfont/emoji
|
2021-04-21 02:12:48 +00:00
|
|
|
|
|
|
|
![nerdfont](https://github.com/ray-x/files/blob/master/img/navigator/icon_nerd.jpg?raw=true)
|
|
|
|
|
2021-04-19 02:56:32 +00:00
|
|
|
# Todo
|
|
|
|
|
2021-04-25 02:43:18 +00:00
|
|
|
- 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)
|
2021-04-24 10:30:31 +00:00
|
|
|
- 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)
|
2021-04-25 02:43:18 +00:00
|
|
|
- Configuration options
|