forked from Archives/navigator.lua
Compare commits
No commits in common. 'master' and 'v0.2.2' have entirely different histories.
@ -1,3 +0,0 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: ray-x
|
|
@ -1,3 +1,3 @@
|
|||||||
selene.toml
|
|
||||||
lua/navigator.lua.bak
|
lua/navigator.lua.bak
|
||||||
tests/fixtures/tests
|
tests/fixtures/tests
|
@ -1,4 +1,4 @@
|
|||||||
function! folding#ngfoldexpr()
|
function! folding#foldexpr()
|
||||||
" return luaeval(printf('require"navigator.foldinglsp".get_fold_indic(%d)', v:lnum))
|
" return luaeval(printf('require"navigator.foldinglsp".get_fold_indic(%d)', v:lnum))
|
||||||
return luaeval(printf('require"navigator.foldts".get_fold_indic(%d)', v:lnum))
|
return luaeval(printf('require"navigator.foldts".get_fold_indic(%d)', v:lnum))
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -1,883 +0,0 @@
|
|||||||
navigator.txt
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
CONTENTS *navigator-contents*
|
|
||||||
|
|
||||||
1. Navigator.................................................|navigator-navigator|
|
|
||||||
1.1. Example: Javascript closure.|navigator-example:_javascript_closure|
|
|
||||||
1.2. Example: C++ definition.......|navigator-example:_c++_definition|
|
|
||||||
1.3. Golang struct type.................|navigator-golang_struct_type|
|
|
||||||
2. Features:.................................................|navigator-features:|
|
|
||||||
3. Why a new plugin...................................|navigator-why_a_new_plugin|
|
|
||||||
4. Similar projects / special mentions:.|navigator-similar_projects_/_special_mentions:|
|
|
||||||
5. Install.....................................................|navigator-install|
|
|
||||||
5.1. Setup...................................................|navigator-setup|
|
|
||||||
5.2. Sample vimrc turning your neovim into a full-featured IDE.|navigator-sample_vimrc_turning_your_neovim_into_a_full-featured_ide|
|
|
||||||
5.3. Work with nvim-cmp and nvim-autopairs.|navigator-work_with_nvim-cmp_and_nvim-autopairs|
|
|
||||||
5.4. All configure options...................|navigator-all_configure_options|
|
|
||||||
5.4.1. LSP clients.................................|navigator-lsp_clients|
|
|
||||||
5.4.1.1. Add your own servers.........|navigator-add_your_own_servers|
|
|
||||||
5.4.2. Disable a lsp client loading from navigator.|navigator-disable_a_lsp_client_loading_from_navigator|
|
|
||||||
5.4.3. Try it your self.......................|navigator-try_it_your_self|
|
|
||||||
5.4.4. Default keymaps.........................|navigator-default_keymaps|
|
|
||||||
5.4.5. Colors/Highlight:.....................|navigator-colors/highlight:|
|
|
||||||
5.5. Dependency.........................................|navigator-dependency|
|
|
||||||
5.6. Integrat with lsp_installer (williamboman/nvim-lsp-installer).|navigator-integrat_with_lsp_installer_(williamboman/nvim-lsp-installer)|
|
|
||||||
5.6.1. Integration with other lsp plugins (e.g. rust-tools, go.nvim, clangd extension).|navigator-integration_with_other_lsp_plugins_(e.g._rust-tools,_go.nvim,_clangd_extension)|
|
|
||||||
5.7. Usage...................................................|navigator-usage|
|
|
||||||
5.8. Configuration...................................|navigator-configuration|
|
|
||||||
5.9. Highlight...........................................|navigator-highlight|
|
|
||||||
5.10. commands............................................|navigator-commands|
|
|
||||||
5.11. Screenshots......................................|navigator-screenshots|
|
|
||||||
5.11.1. Reference....................................|navigator-reference|
|
|
||||||
5.11.2. Definition preview..................|navigator-definition_preview|
|
|
||||||
5.11.3. Sidebar, folding, outline....|navigator-sidebar,_folding,_outline|
|
|
||||||
5.11.4. GUI and multigrid support....|navigator-gui_and_multigrid_support|
|
|
||||||
5.11.5. Document Symbol and navigate through the list.|navigator-document_symbol_and_navigate_through_the_list|
|
|
||||||
5.11.6. Workspace Symbol......................|navigator-workspace_symbol|
|
|
||||||
5.11.7. highlight document symbol and jump between reference.|navigator-highlight_document_symbol_and_jump_between_reference|
|
|
||||||
6. Current symbol highlight and jump backward/forward between symbols.|navigator-current_symbol_highlight_and_jump_backward/forward_between_symbols|
|
|
||||||
6.1. Diagnostic.....................................|navigator-diagnostic|
|
|
||||||
6.2. Edit in preview window.............|navigator-edit_in_preview_window|
|
|
||||||
6.3. Implementation.............................|navigator-implementation|
|
|
||||||
6.4. Fzy search in reference...........|navigator-fzy_search_in_reference|
|
|
||||||
6.5. Code actions.................................|navigator-code_actions|
|
|
||||||
6.6. Symbol rename...............................|navigator-symbol_rename|
|
|
||||||
6.6.1. Fill struct with gopls.......|navigator-fill_struct_with_gopls|
|
|
||||||
6.7. Code preview with highlight...|navigator-code_preview_with_highlight|
|
|
||||||
6.8. Treesitter symbol.......................|navigator-treesitter_symbol|
|
|
||||||
6.9. Signature help.............................|navigator-signature_help|
|
|
||||||
6.10. Call hierarchy (incomming/outgoing calls).|navigator-call_hierarchy_(incomming/outgoing_calls)|
|
|
||||||
6.11. Light bulb if codeAction available.|navigator-light_bulb_if_codeaction_available|
|
|
||||||
6.12. Codelens........................................|navigator-codelens|
|
|
||||||
6.13. Predefined LSP symbol nerdfont/emoji.|navigator-predefined_lsp_symbol_nerdfont/emoji|
|
|
||||||
6.14. VS-code style folding with treesitter.|navigator-vs-code_style_folding_with_treesitter|
|
|
||||||
6.14.1. folding function..................|navigator-folding_function|
|
|
||||||
6.14.2. folding comments..................|navigator-folding_comments|
|
|
||||||
7. Debug the plugin...................................|navigator-debug_the_plugin|
|
|
||||||
8. Break changes and known issues.......|navigator-break_changes_and_known_issues|
|
|
||||||
9. Todo...........................................................|navigator-todo|
|
|
||||||
10. Errors and Bug Reporting..................|navigator-errors_and_bug_reporting|
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
NAVIGATOR *navigator-navigator*
|
|
||||||
|
|
||||||
* Source code analysis and navigate tool
|
|
||||||
* Easy code navigation, view diagnostic errors, see relationships of functions, variables
|
|
||||||
* A plugin combines the power of LSP and 🌲🏡 Treesitter together. Not only provids a better highlight but also help you analyse symbol context effectively.
|
|
||||||
* ctags fuzzy search & build ctags symbols
|
|
||||||
|
|
||||||
-
|
|
||||||
|
|
||||||
* [](https://youtu.be/P1kd7Y8AatE)
|
|
||||||
|
|
||||||
Here are some examples
|
|
||||||
|
|
||||||
EXAMPLE: JAVASCRIPT CLOSURE *navigator-example:_javascript_closure*
|
|
||||||
|
|
||||||
The following screenshot shows javascript call tree 🌲 of variable `browser` insides a closure. This feature is similar to incoming & outgoing calls from LSP. It is designed for the symbol analysis.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Explanation:
|
|
||||||
|
|
||||||
* The first line of floating windows shows there are 3 references for the symbol browser in closure.js
|
|
||||||
* The first reference of browser is an assignment, an emoji 📝 indicates the value is changed in this line. In many
|
|
||||||
cases, we search for references to find out when the value changed.
|
|
||||||
* The second reference of `browser` is inside function `displayName` and `displayName` sit inside `makeFunc`, So you
|
|
||||||
will see `displayName{} <- makeFunc{}`
|
|
||||||
* The third similar to the second, as var browser is on the right side of '=', the value not changed in this line
|
|
||||||
and emoji is not shown.
|
|
||||||
|
|
||||||
EXAMPLE: C++ DEFINITION *navigator-example:_c++_definition*
|
|
||||||
|
|
||||||
C++ example: search reference and definition
|
|
||||||
|
|
||||||
You may find a 🦕 dinosaur(d) on the line of `Rectangle rect,` which means there is a definition (d for def) of rect in this line.
|
|
||||||
|
|
||||||
`<- f main()` means the definition is inside function main().
|
|
||||||
|
|
||||||
GOLANG STRUCT TYPE *navigator-golang_struct_type*
|
|
||||||
|
|
||||||
Struct type references in multiple Go ﳑ files
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This feature can provide you info in which function/class/method the variable was referenced. It is handy for a large
|
|
||||||
project where class/function definition is too long to fit into the preview window. Also provides a bird's eye view of where the
|
|
||||||
variable is:
|
|
||||||
|
|
||||||
* Referenced
|
|
||||||
* Modified
|
|
||||||
* Defined
|
|
||||||
* Called
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
FEATURES: *navigator-features:*
|
|
||||||
|
|
||||||
* LSP easy setup. Support the most commonly used lsp clients setup. Dynamic lsp activation based on buffer type. This
|
|
||||||
also enables you to handle workspace with mixed types of codes (e.g. Go + javascript + yml). A better default setup is
|
|
||||||
included for LSP clients.
|
|
||||||
* Out of box experience. 10 lines of minimum vimrc can turn your neovim into a full-featured LSP & Treesitter powered IDE
|
|
||||||
* UI with floating windows, navigator provides a visual way to manage and navigate through symbols, diagnostic errors, reference etc. It covers
|
|
||||||
all features(handler) provided by LSP from commonly used search reference, to less commonly used search for interface
|
|
||||||
implementation.
|
|
||||||
* Code Action GUI
|
|
||||||
* Luv async thread and tasks
|
|
||||||
* Edit your code in preview window
|
|
||||||
* Async request with lsp.buf_request for reference search
|
|
||||||
* Treesitter symbol search. It is handy for large files (Some of LSP e.g. sumneko_lua, there is a 100kb file size limitation?)
|
|
||||||
* FZY search with either native C (if gcc installed) or Lua-JIT
|
|
||||||
* LSP multiple symbol highlight/marker and hop between document references
|
|
||||||
* Preview definination/references
|
|
||||||
* Better navigation for diagnostic errors, Navigate through all files/buffers that contain errors/warnings
|
|
||||||
* Grouping references/implementation/incoming/outgoing based on file names.
|
|
||||||
* Treesitter based variable/function context analysis. It is 10x times faster compared to purely rely on LSP. In most
|
|
||||||
of the case, it takes treesitter less than 4 ms to read and render all nodes for a file of 1,000 LOC.
|
|
||||||
* The first plugin, IMO, allows you to search in all treesitter symbols in the workspace.
|
|
||||||
* Nerdfont, emoji for LSP and treesitter kind
|
|
||||||
* Optimize display (remove trailing bracket/space), display the caller of reference, de-duplicate lsp results (e.g reference
|
|
||||||
in the same line). Using treesitter for file preview highlighter etc
|
|
||||||
* ccls call hierarchy (Non-standard `ccls/call` API) supports
|
|
||||||
* Syntax folding based on treesitter or LSP_fold folding algorithm. (It behaves similar to vs-code); comment folding
|
|
||||||
* Treesitter symbols sidebar, LSP document symbole sidebar. Both with preview and folding
|
|
||||||
* Fully support LSP CodeAction, CodeLens, CodeLens action. Help you improve code quality.
|
|
||||||
* LRU cache for treesitter nodes
|
|
||||||
* Lazy loader friendly
|
|
||||||
* Multigrid support (different font and detachable)
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
WHY A NEW PLUGIN *navigator-why_a_new_plugin*
|
|
||||||
|
|
||||||
I'd like to go beyond what the system is offering.
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
SIMILAR PROJECTS / SPECIAL MENTIONS: *navigator-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)
|
|
||||||
* fzf-lsp lsp with fzf as gui backend (https://github.com/gfanto/fzf-lsp.nvim)
|
|
||||||
* nvim-treesitter-textobjects (https://github.com/nvim-treesitter/nvim-treesitter-textobjects)
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
INSTALL *navigator-install*
|
|
||||||
|
|
||||||
Require nvim-0.6.1 or above, nightly (0.8) prefered
|
|
||||||
|
|
||||||
You can remove your lspconfig setup and use this plugin.
|
|
||||||
The plugin depends on lspconfig and guihua.lua (https://github.com/ray-x/guihua.lua), which provides GUI and fzy support(migrate from romgrk's project (romgrk/fzy-lua-native)).
|
|
||||||
>
|
|
||||||
Plug 'neovim/nvim-lspconfig'
|
|
||||||
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
|
|
||||||
Plug 'ray-x/navigator.lua'
|
|
||||||
<
|
|
||||||
|
|
||||||
Note: Highly recommend: 'nvim-treesitter/nvim-treesitter'
|
|
||||||
|
|
||||||
Packer
|
|
||||||
>
|
|
||||||
use({
|
|
||||||
'ray-x/navigator.lua',
|
|
||||||
requires = {
|
|
||||||
{ 'ray-x/guihua.lua', run = 'cd lua/fzy && make' },
|
|
||||||
{ 'neovim/nvim-lspconfig' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
<
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
SETUP *navigator-setup*
|
|
||||||
|
|
||||||
Easy setup BOTH lspconfig and navigator with one liner. Navigator covers around 20 most used LSP setup.
|
|
||||||
>
|
|
||||||
lua require'navigator'.setup()
|
|
||||||
<
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
SAMPLE VIMRC TURNING YOUR NEOVIM INTO A FULL-FEATURED IDE *navigator-sample_vimrc_turning_your_neovim_into_a_full-featured_ide*
|
|
||||||
>
|
|
||||||
call plug#begin('~/.vim/plugged')
|
|
||||||
Plug 'neovim/nvim-lspconfig'
|
|
||||||
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
|
|
||||||
Plug 'ray-x/navigator.lua'
|
|
||||||
" Plug 'hrsh7th/nvim-cmp' 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 require('lspconfig'), navigator will configure it for you
|
|
||||||
lua <<EOF
|
|
||||||
require'navigator'.setup()
|
|
||||||
EOF
|
|
||||||
<
|
|
||||||
|
|
||||||
You can remove your lspconfig.lua and use the hooks of navigator.lua. As the
|
|
||||||
navigator will bind keys and handler for you. The LSP will be loaded lazily based on filetype.
|
|
||||||
|
|
||||||
A treesitter only mode. In some cases LSP is buggy or not available, you can also use treesitter
|
|
||||||
standalone
|
|
||||||
>
|
|
||||||
call plug#begin('~/.vim/plugged')
|
|
||||||
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
|
|
||||||
Plug 'ray-x/navigator.lua'
|
|
||||||
" Plug 'hrsh7th/nvim-compe' and other plugins you commenly use...
|
|
||||||
" optional, if you need treesitter symbol support
|
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
||||||
" optional:
|
|
||||||
Plug 'nvim-treesitter/nvim-treesitter-refactor' " this provides "go to def" etc
|
|
||||||
call plug#end()
|
|
||||||
lua <<EOF
|
|
||||||
require'navigator'.setup()
|
|
||||||
EOF
|
|
||||||
<
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
WORK WITH NVIM-CMP AND NVIM-AUTOPAIRS *navigator-work_with_nvim-cmp_and_nvim-autopairs*
|
|
||||||
|
|
||||||
The buffer type of navigator floating windows is `guihua`
|
|
||||||
I would suggest disable `guihua` for autocomplete.
|
|
||||||
e.g.
|
|
||||||
>
|
|
||||||
require('nvim-autopairs').setup{
|
|
||||||
disable_filetype = { "TelescopePrompt" , "guihua", "guihua_rust", "clap_input" },
|
|
||||||
if vim.o.ft == 'clap_input' and vim.o.ft == 'guihua' and vim.o.ft == 'guihua_rust' then
|
|
||||||
require'cmp'.setup.buffer { completion = {enable = false} }
|
|
||||||
end
|
|
||||||
-- or with autocmd
|
|
||||||
vim.cmd("autocmd FileType guihua lua require('cmp').setup.buffer { enabled = false }")
|
|
||||||
vim.cmd("autocmd FileType guihua_rust lua require('cmp').setup.buffer { enabled = false }")
|
|
||||||
...
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
ALL CONFIGURE OPTIONS *navigator-all_configure_options*
|
|
||||||
|
|
||||||
Nondefault configuration example:
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
debug = false, -- log output, set to true and log path: ~/.cache/nvim/gh.log
|
|
||||||
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
|
|
||||||
height = 0.3, -- max list window height, 0.3 by default
|
|
||||||
preview_height = 0.35, -- max height of preview windows
|
|
||||||
border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"}, -- border style, can be one of 'none', 'single', 'double',
|
|
||||||
-- 'shadow', or a list of chars which defines the border
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
-- your hook
|
|
||||||
end,
|
|
||||||
-- put a on_attach of your own here, e.g
|
|
||||||
-- function(client, bufnr)
|
|
||||||
-- -- the on_attach will be called at end of navigator on_attach
|
|
||||||
-- end,
|
|
||||||
-- The attach code will apply to all LSP clients
|
|
||||||
default_mapping = true, -- set to false if you will remap every key
|
|
||||||
keymaps = {{key = "gK", func = "declaration()"}}, -- a list of key maps
|
|
||||||
-- this kepmap gK will override "gD" mapping function declaration() in default kepmap
|
|
||||||
-- please check mapping.lua for all keymaps
|
|
||||||
treesitter_analysis = true, -- treesitter variable context
|
|
||||||
transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque, set to nil or 100 to disable it
|
|
||||||
lsp_signature_help = true, -- if you would like to hook ray-x/lsp_signature plugin in navigator
|
|
||||||
-- setup here. if it is nil, navigator will not init signature help
|
|
||||||
signature_help_cfg = nil, -- if you would like to init ray-x/lsp_signature plugin in navigator, and pass in your own config to signature help
|
|
||||||
icons = {
|
|
||||||
-- Code action
|
|
||||||
code_action_icon = "🏏",
|
|
||||||
-- Diagnostics
|
|
||||||
diagnostic_head = '🐛',
|
|
||||||
diagnostic_head_severity_1 = "🈲",
|
|
||||||
-- refer to lua/navigator.lua for more icons setups
|
|
||||||
},
|
|
||||||
lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer
|
|
||||||
lsp = {
|
|
||||||
enable = true, -- skip lsp setup if disabled make sure add require('navigator.lspclient.mapping').setup() in you
|
|
||||||
-- own on_attach
|
|
||||||
code_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true},
|
|
||||||
code_lens_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true},
|
|
||||||
format_on_save = true, -- set to false to disable lsp code format on save (if you are using prettier/efm/formater etc)
|
|
||||||
disable_format_cap = {"sqls", "sumneko_lua", "gopls"}, -- a list of lsp disable format capacity (e.g. if you using efm or vim-codeformat etc), empty {} by default
|
|
||||||
disable_lsp = {'pylsd', 'sqlls'}, -- a list of lsp server disabled for your project, e.g. denols and tsserver you may
|
|
||||||
-- only want to enable one lsp server
|
|
||||||
-- to disable all default config and use your own lsp setup set
|
|
||||||
-- disable_lsp = 'all'
|
|
||||||
-- Default {}
|
|
||||||
diagnostic = {
|
|
||||||
underline = true,
|
|
||||||
virtual_text = true, -- show virtual for diagnostic message
|
|
||||||
update_in_insert = false, -- update diagnostic message in insert mode
|
|
||||||
},
|
|
||||||
diagnostic_scrollbar_sign = {'▃', '▆', '█'}, -- experimental: diagnostic status in scroll bar area; set to false to disable the diagnostic sign,
|
|
||||||
-- for other style, set to {'╍', 'ﮆ'} or {'-', '='}
|
|
||||||
diagnostic_virtual_text = true, -- show virtual for diagnostic message
|
|
||||||
diagnostic_update_in_insert = false, -- update diagnostic message in insert mode
|
|
||||||
disply_diagnostic_qf = true, -- always show quickfix if there are diagnostic errors, set to false if you want to
|
|
||||||
ignore it
|
|
||||||
tsserver = {
|
|
||||||
filetypes = {'typescript'} -- disable javascript etc,
|
|
||||||
-- set to {} to disable the lspclient for all filetypes
|
|
||||||
},
|
|
||||||
ctags ={
|
|
||||||
cmd = 'ctags',
|
|
||||||
tagfile = 'tags'
|
|
||||||
options = '-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number'
|
|
||||||
}
|
|
||||||
gopls = { -- gopls setting
|
|
||||||
on_attach = function(client, bufnr) -- on_attach for gopls
|
|
||||||
-- your special on attach here
|
|
||||||
-- e.g. disable gopls format because a known issue https://github.com/golang/go/issues/45732
|
|
||||||
print("i am a hook, I will disable document format")
|
|
||||||
client.resolved_capabilities.document_formatting = false
|
|
||||||
end,
|
|
||||||
settings = {
|
|
||||||
gopls = {gofumpt = false} -- disable gofumpt etc,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sumneko_lua = {
|
|
||||||
sumneko_root_path = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server",
|
|
||||||
sumneko_binary = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server/bin/macOS/lua-language-server",
|
|
||||||
},
|
|
||||||
servers = {'cmake', 'ltex'}, -- by default empty, and it should load all LSP clients avalible based on filetype
|
|
||||||
-- but if you whant navigator load e.g. `cmake` and `ltex` for you , you
|
|
||||||
-- can put them in the `servers` list and navigator will auto load them.
|
|
||||||
-- you could still specify the custom config like this
|
|
||||||
-- cmake = {filetypes = {'cmake', 'makefile'}, single_file_support = false},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
<
|
|
||||||
|
|
||||||
LSP CLIENTS *navigator-lsp_clients*
|
|
||||||
|
|
||||||
Built clients:
|
|
||||||
>
|
|
||||||
local servers = {
|
|
||||||
"angularls", "gopls", "tsserver", "flow", "bashls", "dockerls", "julials", "pylsp", "pyright",
|
|
||||||
"jedi_language_server", "jdtls", "sumneko_lua", "vimls", "html", "jsonls", "solargraph", "cssls",
|
|
||||||
"yamlls", "clangd", "ccls", "sqls", "denols", "graphql", "dartls", "dotls",
|
|
||||||
"kotlin_language_server", "nimls", "intelephense", "vuels", "phpactor", "omnisharp",
|
|
||||||
"r_language_server", "rust_analyzer", "terraformls", "svelte", "texlab", "clojure_lsp", "elixirls",
|
|
||||||
"sourcekit", "fsautocomplete", "vls", "hls"
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
Navigator will try to load avalible lsp server/client based on filetype. The clients has none default on_attach.
|
|
||||||
incremental sync and debounce is enabled by navigator. And the lsp
|
|
||||||
snippet will be enabled. So you could use COQ and nvim-cmp snippet expand.
|
|
||||||
|
|
||||||
Other than above setup, additional none default setup are used for following lsp:
|
|
||||||
|
|
||||||
* gopls
|
|
||||||
* clangd
|
|
||||||
* rust_analyzer
|
|
||||||
* sqls
|
|
||||||
* sumneko_lua
|
|
||||||
* pyright
|
|
||||||
* ccls
|
|
||||||
|
|
||||||
Please check client setup (https://github.com/ray-x/navigator.lua/blob/26012cf9c172aa788a2e53018d94b32c5c75af75/lua/navigator/lspclient/clients.lua#L98-L234)
|
|
||||||
|
|
||||||
The plugin can work with multiple LSP, e.g sqls+gopls+efm. But there are cases you may need to disable some of the
|
|
||||||
servers. (Prevent loading multiple LSP for same source code.) e.g. I saw strange behaviours when I use
|
|
||||||
pylsp+pyright+jedi
|
|
||||||
together. If you have multiple similar LSP installed and have trouble with the plugin, please enable only one at a time.
|
|
||||||
|
|
||||||
ADD YOUR OWN SERVERS *navigator-add_your_own_servers*
|
|
||||||
|
|
||||||
Above servers covered a small part neovim lspconfig support, You can still use lspconfig to add and config servers not
|
|
||||||
in the list. If you would like to add a server not in the list, you can check this PR https://github.com/ray-x/navigator.lua/pull/107
|
|
||||||
|
|
||||||
Alternatively, update following option in setup(if you do not want a PR):
|
|
||||||
>
|
|
||||||
require'navigator'setup{lsp={servers={'cmake', 'lexls'}}}
|
|
||||||
<
|
|
||||||
|
|
||||||
Above option add cmake and lexls to the default server list
|
|
||||||
|
|
||||||
DISABLE A LSP CLIENT LOADING FROM NAVIGATOR *navigator-disable_a_lsp_client_loading_from_navigator*
|
|
||||||
|
|
||||||
Note: If you have multiple lsp installed for same language, please only enable one at a time by disable others with e.g. `disable_lsp={'denols', 'clangd'}`
|
|
||||||
To disable a specific LSP, set `filetypes` to {} e.g.
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
lsp={
|
|
||||||
pylsd={filetype={}}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
<
|
|
||||||
|
|
||||||
Or:
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
lsp={
|
|
||||||
disable_lsp = {'pylsd', 'sqlls'},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
<
|
|
||||||
|
|
||||||
TRY IT YOUR SELF *navigator-try_it_your_self*
|
|
||||||
|
|
||||||
In `playground` folder, there is a `init.lua` and source code for you to play with. Check playground/README.md (https://github.com/ray-x/navigator.lua/blob/master/playground/README.md) for more details
|
|
||||||
|
|
||||||
DEFAULT KEYMAPS *navigator-default_keymaps*
|
|
||||||
|
|
||||||
| mode | key | function |
|
|
||||||
| ---- | --------------- | ---------------------------------------------------------- |
|
|
||||||
| n | gr | async references, definitions and context |
|
|
||||||
| n | <Leader>gr | show reference and context |
|
|
||||||
| i | <m-k> | signature help |
|
|
||||||
| n | <c-k> | signature help |
|
|
||||||
| n | gW | workspace symbol |
|
|
||||||
| n | gD | declaration |
|
|
||||||
| n | gd | definition |
|
|
||||||
| n | g0 | document symbol |
|
|
||||||
| n | <C-]> | go to definition (if multiple show listview) |
|
|
||||||
| n | gp | definition preview (Go to Preview) |
|
|
||||||
| n | <C-LeftMouse> | definition |
|
|
||||||
| n | g<LeftMouse> | implementation |
|
|
||||||
| n | <Leader>gt | treesitter document symbol |
|
|
||||||
| n | <Leader>gT | treesitter symbol for all open buffers |
|
|
||||||
| n | <Leader> ct | ctags symbol search |
|
|
||||||
| n | <Leader> cg | ctags symbol generate |
|
|
||||||
| n | K | hover doc |
|
|
||||||
| n | <Space>ca | code action (when you see 🏏 ) |
|
|
||||||
| n | <Space>la | code lens action (when you see a codelens indicator) |
|
|
||||||
| v | <Space>ca | range code action (when you see 🏏 ) |
|
|
||||||
| n | <Space>rn | rename with floating window |
|
|
||||||
| n | <Leader>re | rename (lsp default) |
|
|
||||||
| n | <Leader>gi | hierarchy incoming calls |
|
|
||||||
| n | <Leader>go | hierarchy outgoing calls |
|
|
||||||
| n | gi | implementation |
|
|
||||||
| n | <Space> D | type definition |
|
|
||||||
| n | gL | show line diagnostic |
|
|
||||||
| n | gG | show diagnostic for all buffers |
|
|
||||||
| n | ]d | next diagnostic |
|
|
||||||
| n | [d | previous diagnostic |
|
|
||||||
| n | <Leader> dt | diagnostic toggle(enable/disable) |
|
|
||||||
| n | ]r | next treesitter reference/usage |
|
|
||||||
| n | [r | previous treesitter reference/usage |
|
|
||||||
| n | <Space> wa | add workspace folder |
|
|
||||||
| n | <Space> wr | remove workspace folder |
|
|
||||||
| n | <Space> wl | print workspace folder |
|
|
||||||
| n | <Leader>k | toggle reference highlight |
|
|
||||||
| i/n | <C-p> | previous item in list |
|
|
||||||
| i/n | <C-n> | next item in list |
|
|
||||||
| i/n | number 1~9 | move to ith row/item in the list |
|
|
||||||
| i/n | <Up> | previous item in list |
|
|
||||||
| i/n | <Down> | next item in list |
|
|
||||||
| n | <Ctrl-w>j | move cursor to preview (windows move to bottom view point) |
|
|
||||||
| n | <Ctrl-w>k | move cursor to list (windows move to up view point) |
|
|
||||||
| i/n | <C-o> | open preview file in nvim/Apply action |
|
|
||||||
| n | <C-v> | open preview file in nvim with vsplit |
|
|
||||||
| n | <C-s> | open preview file in nvim with split |
|
|
||||||
| n | <Enter> | open preview file in nvim/Apply action |
|
|
||||||
| n | <ESC> | close listview of floating window |
|
|
||||||
| i/n | <C-e> | close listview of floating window |
|
|
||||||
| i/n | <C-b> | previous page in listview |
|
|
||||||
| i/n | <C-f> | next page in listview |
|
|
||||||
| i/n | <C-s> | save the modification to preview window to file |
|
|
||||||
|
|
||||||
COLORS/HIGHLIGHT: *navigator-colors/highlight:*
|
|
||||||
|
|
||||||
You can override default highlight GuihuaListDark (listview) and GuihuaTextViewDark (code view) and GuihuaListHl (select item)
|
|
||||||
|
|
||||||
e.g.
|
|
||||||
>
|
|
||||||
hi default GuihuaTextViewDark guifg=#e0d8f4 guibg=#332e55
|
|
||||||
hi default GuihuaListDark guifg=#e0d8f4 guibg=#103234
|
|
||||||
hi default GuihuaListHl guifg=#e0d8f4 guibg=#404254
|
|
||||||
<
|
|
||||||
|
|
||||||
There are other Lsp highlight been used in this plugin, e.g LspReferenceRead/Text/Write are used for document highlight,
|
|
||||||
LspDiagnosticsXXX are used for diagnostic. Please check highlight.lua and dochighlight.lua for more info.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
DEPENDENCY *navigator-dependency*
|
|
||||||
|
|
||||||
* lspconfig
|
|
||||||
* guihua.lua (provides floating window, FZY)
|
|
||||||
* Optional:
|
|
||||||
* treesitter (list treesitter symbols, object analysis)
|
|
||||||
* 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.
|
|
||||||
|
|
||||||
The terminal will need to be able to output nerdfont and emoji correctly. I am using Kitty with nerdfont (Victor Mono).
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
INTEGRAT WITH LSP_INSTALLER (WILLIAMBOMAN/NVIM-LSP-INSTALLER) *navigator-integrat_with_lsp_installer_(williamboman/nvim-lsp-installer)*
|
|
||||||
|
|
||||||
If you are using lsp_installer and would like to use the lsp servers installed by lsp_installer. Please set
|
|
||||||
>
|
|
||||||
lsp_installer = true
|
|
||||||
<
|
|
||||||
|
|
||||||
In the config. Also please setup the lsp server from installer setup with `server:setup{opts}`
|
|
||||||
|
|
||||||
example:
|
|
||||||
>
|
|
||||||
use({
|
|
||||||
'williamboman/nvim-lsp-installer',
|
|
||||||
config = function()
|
|
||||||
local lsp_installer = require('nvim-lsp-installer')
|
|
||||||
lsp_installer.setup{}
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use({
|
|
||||||
'ray-x/navigator.lua',
|
|
||||||
config = function()
|
|
||||||
require('navigator').setup({
|
|
||||||
debug = true,
|
|
||||||
lsp_installer = true,
|
|
||||||
keymaps = { { key = 'gR', func = "require('navigator.reference').async_ref()" } },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
<
|
|
||||||
|
|
||||||
Please refer to lsp_installer_config (https://github.com/ray-x/navigator.lua/blob/master/playground/init_lsp_installer.lua)
|
|
||||||
for more info
|
|
||||||
|
|
||||||
Alternatively, Navigator can be used to startup the server installed by lsp-installer.
|
|
||||||
as it will override the navigator setup
|
|
||||||
|
|
||||||
To start LSP installed by lsp_installer, please use following setups
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
-- lsp_installer = false -- default value is false
|
|
||||||
lsp = {
|
|
||||||
tsserver = { cmd = {'your tsserver installed by lsp_installer'} }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
<
|
|
||||||
|
|
||||||
example cmd setup (mac) for pyright :
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
-- lsp_installer = false -- default value is false
|
|
||||||
lsp = {
|
|
||||||
tsserver = {
|
|
||||||
cmd = { "/Users/username/.local/share/nvim/lsp_servers/python/node_modules/.bin/pyright-langserver", "--stdio" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
The lsp servers installed by nvim-lsp-installer is in following dir
|
|
||||||
>
|
|
||||||
local path = require 'nvim-lsp-installer.path'
|
|
||||||
local install_root_dir = path.concat {vim.fn.stdpath 'data', 'lsp_servers'}
|
|
||||||
<
|
|
||||||
|
|
||||||
And you can setup binary full path to this: (e.g. with gopls)
|
|
||||||
`install_root_dir .. '/go/gopls'` So the config is
|
|
||||||
>
|
|
||||||
local path = require 'nvim-lsp-installer.path'
|
|
||||||
local install_root_dir = path.concat {vim.fn.stdpath 'data', 'lsp_servers'}
|
|
||||||
require'navigator'.setup({
|
|
||||||
-- lsp_installer = false -- default value is false
|
|
||||||
lsp = {
|
|
||||||
gopls = {
|
|
||||||
cmd = { install_root_dir .. '/go/gopls' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
Use lsp_installer configs
|
|
||||||
You can delegate the lsp server setup to lsp_installer with `server:setup{opts}`
|
|
||||||
Here is an example init_lsp_installer.lua (https://github.com/ray-x/navigator.lua/blob/master/playground/init_lsp_installer.lua)
|
|
||||||
|
|
||||||
INTEGRATION WITH OTHER LSP PLUGINS (E.G. RUST-TOOLS, GO.NVIM, CLANGD EXTENSION) *navigator-integration_with_other_lsp_plugins_(e.g._rust-tools,_go.nvim,_clangd_extension)*
|
|
||||||
|
|
||||||
There are lots of plugins provides lsp support
|
|
||||||
go.nvim allow you either hook gopls from go.nvim or from navigator and it can export the lsp setup from go.nvim.
|
|
||||||
|
|
||||||
rust-tools and clangd allow you to setup on_attach from config server
|
|
||||||
Here is an example to setup rust with rust-tools
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
lsp = {
|
|
||||||
disable_lsp = { "rust_analyzer", "clangd" }, -- will not run rust_analyzer setup from navigator
|
|
||||||
}
|
|
||||||
})
|
|
||||||
require('rust-tools').setup({
|
|
||||||
server = {
|
|
||||||
on_attach = function(_, _)
|
|
||||||
require('navigator.lspclient.mapping').setup() -- setup navigator keymaps here,
|
|
||||||
-- otherwise, you can define your own commands to call navigator functions
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
require("clangd_extensions").setup {
|
|
||||||
server = {
|
|
||||||
on_attach = function(_, _)
|
|
||||||
require('navigator.lspclient.mapping').setup() -- setup navigator keymaps here,
|
|
||||||
-- otherwise, you can define your own commands to call navigator functions
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
USAGE *navigator-usage*
|
|
||||||
|
|
||||||
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
|
|
||||||
* (or <c-n>, <c-p>) to move
|
|
||||||
* <c-o> or <CR> to open location or apply code actions. Note: <CR> might be bound in insert mode by other plugins
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
CONFIGURATION *navigator-configuration*
|
|
||||||
|
|
||||||
In `navigator.lua` there is a default configuration. You can override the values by passing your own values
|
|
||||||
|
|
||||||
e.g
|
|
||||||
>
|
|
||||||
-- The attach will be call at end of navigator on_attach()
|
|
||||||
require'navigator'.setup({on_attach = function(client, bufnr) require 'illuminate'.on_attach(client)})
|
|
||||||
<
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
HIGHLIGHT *navigator-highlight*
|
|
||||||
|
|
||||||
Highlight I am using:
|
|
||||||
|
|
||||||
* LspReferenceRead, LspReferenceText and LspReferenceWrite are used for `autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()`
|
|
||||||
That is where you saw the current symbol been highlighted.
|
|
||||||
* GuihuaListDark and GuihuaTextViewDark is used for floating listvew and TextView. They are be based on current background
|
|
||||||
(Normal) and PmenuSel
|
|
||||||
* In future, I will use NormalFloat for floating view. But ATM, most of colorscheme does not define NormalFloat
|
|
||||||
|
|
||||||
You can override the above highlight to fit your current colorscheme
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
COMMANDS *navigator-commands*
|
|
||||||
|
|
||||||
| command | function |
|
|
||||||
| ------------ | ------------------------- |
|
|
||||||
| LspToggleFmt | toggle lsp auto format |
|
|
||||||
| LspKeymaps | show LSP releated keymaps |
|
|
||||||
| Nctags {args} | show ctags symbols, args: -g regen ctags |
|
|
||||||
| LspRestart | reload lsp |
|
|
||||||
| LspSymbols | document symbol in side panel |
|
|
||||||
| NRefPanel |symbol reference in side panel |
|
|
||||||
| TSymobls | treesitter symbol in side panel |
|
|
||||||
| Calltree {args} | lsp call hierarchy call tree, args: -i (incomming default), -o (outgoing) |
|
|
||||||
|
|
||||||
:LspToggleFmt *:LspToggleFmt*
|
|
||||||
Toggle lsp auto format.
|
|
||||||
|
|
||||||
:LspKeymaps *:LspKeymaps*
|
|
||||||
Show Lsp keymaps.
|
|
||||||
|
|
||||||
:Nctags [flags] *:Nctags*
|
|
||||||
Show ctags symbols.
|
|
||||||
[flags]:
|
|
||||||
-g regen ctags
|
|
||||||
|
|
||||||
:LspRestart *:LspRestart*
|
|
||||||
Restart Lsp.
|
|
||||||
|
|
||||||
:LspSymbols *:LspSymbols*
|
|
||||||
Lsp document symbol in side panel.
|
|
||||||
|
|
||||||
:TSSymbols *:TSSymbols*
|
|
||||||
Treesitter symbol in side panel.
|
|
||||||
|
|
||||||
:NRefPanel *:NRefPanel*
|
|
||||||
Symbol reference in side panel.
|
|
||||||
|
|
||||||
:Calltree [flags] *:Calltree*
|
|
||||||
Lsp call hierarchy call tree.
|
|
||||||
[flags]:
|
|
||||||
-i: incomming default
|
|
||||||
-o: outgoing
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
SCREENSHOTS *navigator-screenshots*
|
|
||||||
|
|
||||||
colorscheme: aurora (https://github.com/ray-x/aurora)
|
|
||||||
|
|
||||||
REFERENCE *navigator-reference*
|
|
||||||
|
|
||||||
Pls check the first part of README
|
|
||||||
|
|
||||||
DEFINITION PREVIEW *navigator-definition_preview*
|
|
||||||
|
|
||||||
Using treesitter and LSP to view the symbol definition
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SIDEBAR, FOLDING, OUTLINE *navigator-sidebar,_folding,_outline*
|
|
||||||
|
|
||||||
Treesitter outline and Diagnostics
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GUI AND MULTIGRID SUPPORT *navigator-gui_and_multigrid_support*
|
|
||||||
|
|
||||||
You can load a different font size for floating win
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENT SYMBOL AND NAVIGATE THROUGH THE LIST *navigator-document_symbol_and_navigate_through_the_list*
|
|
||||||
|
|
||||||
|
|
||||||
The key binding to navigate in the list.
|
|
||||||
|
|
||||||
* up and down key
|
|
||||||
* `<Ctrl-f/b>` for page up and down
|
|
||||||
* number key 1~9 go to the ith item.
|
|
||||||
* If there are loads of results, would be good to use fzy search prompt to filter out the result you are interested.
|
|
||||||
|
|
||||||
WORKSPACE SYMBOL *navigator-workspace_symbol*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HIGHLIGHT DOCUMENT SYMBOL AND JUMP BETWEEN REFERENCE *navigator-highlight_document_symbol_and_jump_between_reference*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
CURRENT SYMBOL HIGHLIGHT AND JUMP BACKWARD/FORWARD BETWEEN SYMBOLS *navigator-current_symbol_highlight_and_jump_backward/forward_between_symbols*
|
|
||||||
|
|
||||||
Document highlight provided by LSP.
|
|
||||||
Jump between symbols with treesitter (with `]r` and `[r`)
|
|
||||||
|
|
||||||
|
|
||||||
DIAGNOSTIC *navigator-diagnostic*
|
|
||||||
|
|
||||||
Visual studio code style show errors minimap in scroll bar area
|
|
||||||
(Check setup for `diagnostic_scrollbar_sign`)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Diagnostic in single bufer
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Show diagnostic in all buffers
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EDIT IN PREVIEW WINDOW *navigator-edit_in_preview_window*
|
|
||||||
|
|
||||||
You can in place edit your code in floating window
|
|
||||||
|
|
||||||
https://user-images.githubusercontent.com/1681295/121832919-89cbc080-cd0e-11eb-9778-11d0f356b38d.mov
|
|
||||||
|
|
||||||
(Note: This feature only avalible in `find reference` and `find diagnostic`, You can not add/remove lines in floating window)
|
|
||||||
|
|
||||||
IMPLEMENTATION *navigator-implementation*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FZY SEARCH IN REFERENCE *navigator-fzy_search_in_reference*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CODE ACTIONS *navigator-code_actions*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SYMBOL RENAME *navigator-symbol_rename*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FILL STRUCT WITH GOPLS *navigator-fill_struct_with_gopls*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CODE PREVIEW WITH HIGHLIGHT *navigator-code_preview_with_highlight*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TREESITTER SYMBOL *navigator-treesitter_symbol*
|
|
||||||
|
|
||||||
Treetsitter symbols in all buffers
|
|
||||||
|
|
||||||
|
|
||||||
SIGNATURE HELP *navigator-signature_help*
|
|
||||||
|
|
||||||
Improved signature help with current parameter highlighted
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CALL HIERARCHY (INCOMMING/OUTGOING CALLS) *navigator-call_hierarchy_(incomming/outgoing_calls)*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LIGHT BULB IF CODEACTION AVAILABLE *navigator-light_bulb_if_codeaction_available*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CODELENS *navigator-codelens*
|
|
||||||
|
|
||||||
Codelens for gopls/golang. Garbage collection analyse:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Codelens for C++/ccls. Symbol reference
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PREDEFINED LSP SYMBOL NERDFONT/EMOJI *navigator-predefined_lsp_symbol_nerdfont/emoji*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VS-CODE STYLE FOLDING WITH TREESITTER *navigator-vs-code_style_folding_with_treesitter*
|
|
||||||
|
|
||||||
FOLDING FUNCTION *navigator-folding_function*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FOLDING COMMENTS *navigator-folding_comments*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
DEBUG THE PLUGIN *navigator-debug_the_plugin*
|
|
||||||
|
|
||||||
One simple way to gether debug info and understand what is wrong is output the debug logs
|
|
||||||
>
|
|
||||||
require'navigator'.setup({
|
|
||||||
debug = false, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
|
|
||||||
})
|
|
||||||
<
|
|
||||||
>
|
|
||||||
-- a example of adding logs in the plugin
|
|
||||||
local log = require"navigator.util".log
|
|
||||||
local definition_hdlr = util.mk_handler(function(err, locations, ctx, _)
|
|
||||||
-- output your log
|
|
||||||
log('[definition] log for locations', locations, "and ctx", ctx)
|
|
||||||
if err ~= nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
<
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BREAK CHANGES AND KNOWN ISSUES *navigator-break_changes_and_known_issues*
|
|
||||||
|
|
||||||
known issues I am working on (https://github.com/ray-x/navigator.lua/issues/1)
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
TODO *navigator-todo*
|
|
||||||
|
|
||||||
* The project is in the early phase, bugs expected, PRs 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. Did not test other languages (e.g dart, swift etc)
|
|
||||||
* Configuration options
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
ERRORS AND BUG REPORTING *navigator-errors_and_bug_reporting*
|
|
||||||
|
|
||||||
* Please double check your setup and check if minium setup works or not
|
|
||||||
* It should works for 0.6.1, neovim 0.7.x prefered.
|
|
||||||
* Check console output
|
|
||||||
* Check `LspInfo` and treesitter status with `checkhealth`
|
|
||||||
* Turn on log and attach the log to your issue if possible you can remove any personal/company info in the log
|
|
||||||
* Submit Issue with minium vimrc. Please check playground/init.lua as a vimrc template. !!!Please DONOT use a packer vimrc
|
|
||||||
|
|
||||||
that installs everything to default folder!!! Also check this repo navigator bug report (https://github.com/fky2015/navigator.nvim-bug-report)
|
|
@ -1,4 +0,0 @@
|
|||||||
autocmd BufRead,BufNewFile *.tf,*.tfvars set filetype=terraform
|
|
||||||
autocmd BufRead,BufNewFile *.tfstate,*.tfstate.backup set filetype=json
|
|
||||||
autocmd BufRead,BufNewFile *.hcl set filetype=hcl
|
|
||||||
autocmd BufRead,BufNewFile .terraformrc,terraform.rc set filetype=hcl
|
|
@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title></title>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="css/style.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,177 +0,0 @@
|
|||||||
local type_to_lspkind = { c = 5, m = 7, f = 6, s = 5 }
|
|
||||||
local util = require('navigator.util')
|
|
||||||
local log = util.log
|
|
||||||
local sep = util.path_sep()
|
|
||||||
local vfn = vim.fn
|
|
||||||
local cur_dir = vfn.getcwd()
|
|
||||||
|
|
||||||
-- convert ctags line to lsp entry
|
|
||||||
local function entry_to_item(entry)
|
|
||||||
local item = {}
|
|
||||||
item.name, item.filename, item.line, item.remain = string.match(entry, '(.*)\t(.*)\t(%d+);(.*)')
|
|
||||||
local type = 'combine'
|
|
||||||
item.remain = item.remain or ''
|
|
||||||
if item.remain:sub(1, 1) == [["]] then
|
|
||||||
type = 'number'
|
|
||||||
end
|
|
||||||
if item.name == nil or item.filename == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if type == 'combine' then
|
|
||||||
-- '/^type ServerResponse struct {$/;"\ts\tpackage:client'
|
|
||||||
item.inline, item.type, item.containerName, item.ref = string.match(item.remain, '/^(.*)$/;"\t(%a)\t(.+)')
|
|
||||||
else
|
|
||||||
-- '"\tm\tstruct:store.Customer\ttyperef:typename:string'
|
|
||||||
item.type, item.containerName, item.ref = string.match(item.remain, '"\t(%a)\t(.+)')
|
|
||||||
end
|
|
||||||
item.kind = type_to_lspkind[item.type] or 13
|
|
||||||
item.lnum = tonumber(item.line) - 1
|
|
||||||
item.location = {
|
|
||||||
uri = 'file://' .. cur_dir .. sep .. item.filename,
|
|
||||||
range = {
|
|
||||||
start = { line = item.lnum, character = 0 },
|
|
||||||
['end'] = { line = item.lnum, character = 0 },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
item.uri = 'file://' .. cur_dir .. sep .. item.filename
|
|
||||||
item.range = {
|
|
||||||
start = { line = item.lnum, character = 0 },
|
|
||||||
['end'] = { line = item.lnum, character = 0 },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- item.detail = (item.containerName or '') .. (item.ref or '')
|
|
||||||
-- item.text = '[' .. kind .. ']' .. item.name .. ' ' .. item.detail
|
|
||||||
|
|
||||||
if item.lnum == nil then
|
|
||||||
vim.notify('incorrect ctags format, need run ctag with "-excmd=number|combine" option')
|
|
||||||
end
|
|
||||||
item.remain = nil
|
|
||||||
return item
|
|
||||||
end
|
|
||||||
|
|
||||||
local function ctags_gen()
|
|
||||||
local cmd = 'ctags' -- -x -n -u -f - ' .. vfn.expand('%:p')
|
|
||||||
local output = _NgConfigValues.ctags.tagfile
|
|
||||||
-- rm file first
|
|
||||||
util.rm_file(output)
|
|
||||||
local options = '-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number '
|
|
||||||
if _NgConfigValues.ctags then
|
|
||||||
cmd = _NgConfigValues.ctags.cmd
|
|
||||||
options = _NgConfigValues.ctags.options or options
|
|
||||||
end
|
|
||||||
|
|
||||||
local lang = vim.o.ft
|
|
||||||
options = options .. '--language=' .. lang
|
|
||||||
cmd = cmd .. ' ' .. options
|
|
||||||
cmd = string.format('%s -f %s %s --language=%s', cmd, output, options, lang)
|
|
||||||
cmd = vim.split(cmd, ' ')
|
|
||||||
log(cmd)
|
|
||||||
vfn.jobstart(cmd, {
|
|
||||||
on_stdout = function(_, _, _)
|
|
||||||
vim.notify('ctags completed')
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_exit = function(_, data, _) -- id, data, event
|
|
||||||
-- log(vim.inspect(data) .. "exit")
|
|
||||||
if data and data ~= 0 then
|
|
||||||
return vim.notify(cmd .. ' failed ' .. tostring(data), vim.lsp.log_levels.ERROR)
|
|
||||||
else
|
|
||||||
vim.notify('ctags generated')
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
local symbols_to_items = require('navigator.lspwrapper').symbols_to_items
|
|
||||||
local function ctags_symbols()
|
|
||||||
local height = _NgConfigValues.height or 0.4
|
|
||||||
local width = _NgConfigValues.width or 0.7
|
|
||||||
height = math.floor(height * vfn.winheight('%'))
|
|
||||||
width = math.floor(vim.api.nvim_get_option('columns') * width)
|
|
||||||
local items = {}
|
|
||||||
local ctags_file = _NgConfigValues.ctags.tagfile
|
|
||||||
if not util.file_exists(ctags_file) then
|
|
||||||
ctags_gen()
|
|
||||||
vim.cmd('sleep 200m')
|
|
||||||
end
|
|
||||||
local cnts = util.io_read(ctags_file)
|
|
||||||
if cnts == nil then
|
|
||||||
return vim.notify('ctags file ' .. ctags_file .. ' not found')
|
|
||||||
end
|
|
||||||
cnts = vfn.split(cnts, '\n')
|
|
||||||
for _, value in pairs(cnts) do
|
|
||||||
local it = entry_to_item(value)
|
|
||||||
if it then
|
|
||||||
table.insert(items, it)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
cnts = nil
|
|
||||||
|
|
||||||
local ft = vim.o.ft
|
|
||||||
local result = symbols_to_items(items)
|
|
||||||
if next(result) == nil then
|
|
||||||
return vim.notify('no symbols found')
|
|
||||||
end
|
|
||||||
log(result[1])
|
|
||||||
local opt = {
|
|
||||||
api = ' ',
|
|
||||||
ft = ft,
|
|
||||||
bg = 'GuihuaListDark',
|
|
||||||
data = result,
|
|
||||||
items = result,
|
|
||||||
enter = true,
|
|
||||||
loc = 'top_center',
|
|
||||||
transparency = 50,
|
|
||||||
prompt = true,
|
|
||||||
rawdata = true,
|
|
||||||
rect = { height = height, pos_x = 0, pos_y = 0, width = width },
|
|
||||||
}
|
|
||||||
|
|
||||||
require('navigator.gui').new_list_view(opt)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- gen_ctags()
|
|
||||||
|
|
||||||
local function ctags(...)
|
|
||||||
local gen = select(1, ...)
|
|
||||||
log(gen)
|
|
||||||
if gen == '-g' then
|
|
||||||
ctags_gen()
|
|
||||||
vim.cmd('sleep 200m')
|
|
||||||
ctags_symbols()
|
|
||||||
else
|
|
||||||
ctags_symbols()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function testitem()
|
|
||||||
local e = [[ServerResponse internal/clients/server.go /^type ServerResponse struct {$/;" s package:client]]
|
|
||||||
local ecombine = [[ServerResponse internal/clients/server.go 5;/^type ServerResponse struct {$/;" s package:client]]
|
|
||||||
local enumber = [[CustomerID internal/store/models.go 17;" m struct:store.Customer typeref:typename:string]]
|
|
||||||
local enumber2 = [[CustomerDescription internal/controllers/customer.go 27;" c package:controllers]]
|
|
||||||
local enumber3 = [[add_servers lua/navigator/lspclient/clients.lua 680;" f]]
|
|
||||||
local i = entry_to_item(ecombine)
|
|
||||||
print(vim.inspect(i))
|
|
||||||
|
|
||||||
i = entry_to_item(enumber)
|
|
||||||
print(vim.inspect(i))
|
|
||||||
|
|
||||||
i = entry_to_item(enumber2)
|
|
||||||
print(vim.inspect(i))
|
|
||||||
|
|
||||||
i = entry_to_item(enumber3)
|
|
||||||
print(vim.inspect(i))
|
|
||||||
i = entry_to_item(e)
|
|
||||||
print(vim.inspect(i))
|
|
||||||
end
|
|
||||||
-- testitem()
|
|
||||||
-- gen_ctags()
|
|
||||||
-- ctags_symbols()
|
|
||||||
|
|
||||||
return {
|
|
||||||
ctags_gen = ctags_gen,
|
|
||||||
ctags = ctags,
|
|
||||||
ctags_symbols = ctags_symbols,
|
|
||||||
}
|
|
@ -1,312 +1,102 @@
|
|||||||
local gui = require('navigator.gui')
|
local gui = require "navigator.gui"
|
||||||
local util = require('navigator.util')
|
local util = require "navigator.util"
|
||||||
local log = util.log
|
local log = util.log
|
||||||
local trace = util.trace
|
local trace = util.trace
|
||||||
local partial = util.partial
|
local partial = util.partial
|
||||||
local lsphelper = require('navigator.lspwrapper')
|
local lsphelper = require "navigator.lspwrapper"
|
||||||
|
|
||||||
local path_sep = require('navigator.util').path_sep()
|
local path_sep = require"navigator.util".path_sep()
|
||||||
local path_cur = require('navigator.util').path_cur()
|
local path_cur = require"navigator.util".path_cur()
|
||||||
local cwd = vim.loop.cwd()
|
local cwd = vim.loop.cwd()
|
||||||
local in_method = 'callHierarchy/incomingCalls'
|
|
||||||
local out_method = 'callHierarchy/outgoingCalls'
|
|
||||||
|
|
||||||
local lsp_method = { to = out_method, from = in_method }
|
|
||||||
local panel_method = { to = out_method, from = in_method }
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
local outgoing_calls_handler
|
local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_message)
|
||||||
local incoming_calls_handler
|
|
||||||
local hierarchy_handler
|
|
||||||
|
|
||||||
local call_hierarchy
|
|
||||||
|
|
||||||
local function pick_call_hierarchy_item(call_hierarchy_items)
|
|
||||||
if not call_hierarchy_items then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if #call_hierarchy_items == 1 then
|
|
||||||
return call_hierarchy_items[1]
|
|
||||||
end
|
|
||||||
local items = {}
|
|
||||||
for i, item in pairs(call_hierarchy_items) do
|
|
||||||
local entry = item.detail or item.name
|
|
||||||
table.insert(items, string.format('%d. %s', i, entry))
|
|
||||||
end
|
|
||||||
local choice = vim.fn.inputlist(items)
|
|
||||||
if choice < 1 or choice > #items then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
return choice
|
|
||||||
end
|
|
||||||
|
|
||||||
-- convert lsp result to navigator items
|
|
||||||
local function call_hierarchy_result_procesor(direction, err, result, ctx, config)
|
|
||||||
math.randomseed(os.clock() * 100000000000)
|
|
||||||
trace(direction, err, ctx, config)
|
|
||||||
trace(result)
|
|
||||||
if not result then
|
if not result then
|
||||||
vim.notify('No call hierarchy items found', vim.lsp.log_levels.WARN)
|
print("No call hierarchy items found")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- trace('call_hierarchy', result)
|
trace('call_hierarchy', result)
|
||||||
|
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags")
|
||||||
local bufnr = ctx.bufnr or vim.api.nvim_get_current_buf()
|
|
||||||
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use call hierarchy')
|
|
||||||
if err ~= nil then
|
if err ~= nil then
|
||||||
log('dir', direction, 'result', result, 'err', err, ctx)
|
log("dir", direction, "result", result, "err", err, ctx)
|
||||||
vim.notify('ERROR: ' .. err, vim.lsp.log_levels.WARN)
|
print("ERROR: " .. error_message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local items = ctx.items or {}
|
local items = {}
|
||||||
|
|
||||||
|
for _, call_hierarchy_call in pairs(result) do
|
||||||
|
local call_hierarchy_item = call_hierarchy_call[direction]
|
||||||
local kind = ' '
|
local kind = ' '
|
||||||
for _, call_hierarchy_result in pairs(result) do
|
|
||||||
local call_hierarchy_item = call_hierarchy_result[direction]
|
|
||||||
if call_hierarchy_item.kind then
|
if call_hierarchy_item.kind then
|
||||||
kind = require('navigator.lspclient.lspkind').symbol_kind(call_hierarchy_item.kind) .. ' '
|
kind = require'navigator.lspclient.lspkind'.symbol_kind(call_hierarchy_item.kind) .. ' '
|
||||||
end
|
end
|
||||||
|
-- for _, range in pairs(call_hierarchy_call.fromRanges) do
|
||||||
|
range = call_hierarchy_item.range or call_hierarchy_item.selectionRange
|
||||||
local filename = assert(vim.uri_to_fname(call_hierarchy_item.uri))
|
local filename = assert(vim.uri_to_fname(call_hierarchy_item.uri))
|
||||||
local display_filename = filename:gsub(cwd .. path_sep, path_cur, 1)
|
local display_filename = filename:gsub(cwd .. path_sep, path_cur, 1)
|
||||||
call_hierarchy_item.detail = call_hierarchy_item.detail or ''
|
call_hierarchy_item.detail = call_hierarchy_item.detail or ""
|
||||||
call_hierarchy_item.detail = string.gsub(call_hierarchy_item.detail, '\n', ' ↳ ')
|
call_hierarchy_item.detail = call_hierarchy_item.detail:gsub("\n", " ↳ ")
|
||||||
trace(call_hierarchy_item)
|
trace(range, call_hierarchy_item)
|
||||||
|
|
||||||
local disp_item = vim.tbl_deep_extend('force', {}, call_hierarchy_item)
|
local disp_item = {
|
||||||
disp_item = vim.tbl_deep_extend('force', disp_item, {
|
uri = call_hierarchy_item.uri,
|
||||||
filename = filename,
|
filename = filename,
|
||||||
display_filename = display_filename,
|
display_filename = display_filename,
|
||||||
indent_level = ctx.depth or 1,
|
|
||||||
method = lsp_method[direction],
|
|
||||||
node_text = call_hierarchy_item.name,
|
|
||||||
type = kind,
|
|
||||||
id = math.random(1, 100000),
|
|
||||||
text = kind .. call_hierarchy_item.name .. ' ﰲ ' .. call_hierarchy_item.detail,
|
text = kind .. call_hierarchy_item.name .. ' ﰲ ' .. call_hierarchy_item.detail,
|
||||||
lnum = call_hierarchy_item.selectionRange.start.line + 1,
|
range = range,
|
||||||
col = call_hierarchy_item.selectionRange.start.character,
|
lnum = range.start.line + 1,
|
||||||
})
|
col = range.start.character
|
||||||
table.insert(items, disp_item)
|
|
||||||
end
|
|
||||||
trace(items)
|
|
||||||
return items
|
|
||||||
end
|
|
||||||
|
|
||||||
local call_hierarchy_handler_from = partial(call_hierarchy_result_procesor, 'from')
|
|
||||||
local call_hierarchy_handler_to = partial(call_hierarchy_result_procesor, 'to')
|
|
||||||
|
|
||||||
-- the handler that deal all lsp request
|
|
||||||
hierarchy_handler = function(dir, handler, show, api, err, result, ctx, cfg)
|
|
||||||
trace(dir, handler, api, show, err, result, ctx, cfg)
|
|
||||||
ctx = ctx or {} -- can be nil if it is async call
|
|
||||||
cfg = cfg or {}
|
|
||||||
local opts = ctx.opts or {}
|
|
||||||
vim.validate({ handler = { handler, 'function' }, show = { show, 'function' }, api = { api, 'string' } })
|
|
||||||
local bufnr = ctx.bufnr or vim.api.nvim_get_current_buf()
|
|
||||||
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp hierarchy')
|
|
||||||
|
|
||||||
local results = handler(err, result, ctx, cfg, 'Incoming calls not found')
|
|
||||||
|
|
||||||
local ft = vim.api.nvim_buf_get_option(ctx.bufnr or vim.api.nvim_get_current_buf(), 'ft')
|
|
||||||
if ctx.no_show then
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
-- local panel = args.panel
|
|
||||||
-- local items = args.items
|
|
||||||
-- local parent_node = args.node
|
|
||||||
-- local section_id = args.section_id or 1
|
|
||||||
local show_args = {
|
|
||||||
items = results,
|
|
||||||
ft = ft,
|
|
||||||
api = api,
|
|
||||||
bufnr = bufnr,
|
|
||||||
panel = opts.panel,
|
|
||||||
parent_node = opts.parent_node,
|
|
||||||
}
|
}
|
||||||
local win = show(show_args)
|
|
||||||
return results, win
|
|
||||||
end
|
|
||||||
|
|
||||||
local make_params = function(uri, pos)
|
table.insert(items, disp_item)
|
||||||
return {
|
-- end
|
||||||
textDocument = {
|
|
||||||
uri = uri,
|
|
||||||
},
|
|
||||||
position = pos,
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function display_panel(args)
|
|
||||||
-- args = {items=results, ft=ft, api=api}
|
|
||||||
log(args)
|
|
||||||
|
|
||||||
local Panel = require('guihua.panel')
|
|
||||||
local bufnr = args.bufnr or vim.api.nvim_get_current_buf()
|
|
||||||
-- local ft = args.ft or vim.api.nvim_buf_get_option(bufnr, 'buftype')
|
|
||||||
local items = args.items
|
|
||||||
local p = Panel:new({
|
|
||||||
header = args.header or 'Call Hierarchy',
|
|
||||||
render = function(buf)
|
|
||||||
log(buf)
|
|
||||||
return items
|
return items
|
||||||
end,
|
|
||||||
fold = function(panel, node)
|
|
||||||
if node.expanded ~= nil then
|
|
||||||
node.expanded = not node.expanded
|
|
||||||
vim.cmd('normal! za')
|
|
||||||
else
|
|
||||||
expand(panel, node)
|
|
||||||
node.expanded = true
|
|
||||||
end
|
|
||||||
log('fold')
|
|
||||||
return node
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
p:open(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function expand_item(args)
|
|
||||||
-- args = {items=results, ft=ft, api=api}
|
|
||||||
print('dispaly panel')
|
|
||||||
trace(args, args.parent_node)
|
|
||||||
local panel = args.panel
|
|
||||||
local items = args.items
|
|
||||||
local parent_node = args.parent_node
|
|
||||||
local section_id = args.section_id or 1
|
|
||||||
|
|
||||||
local sect
|
|
||||||
local sectid = 1
|
|
||||||
for i, s in pairs(panel.sections) do
|
|
||||||
if s.id == section_id then
|
|
||||||
sectid = i
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
sect = panel.sections[sectid]
|
|
||||||
for i, node in pairs(sect.nodes) do
|
|
||||||
if node.id == parent_node.id then
|
|
||||||
for j in ipairs(items) do
|
|
||||||
items[j].indent_level = parent_node.indent_level + 1
|
|
||||||
table.insert(sect.nodes, i + j, args.items[j])
|
|
||||||
end
|
|
||||||
sect.nodes[i].expanded = true
|
|
||||||
sect.nodes[i].expandable = false
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
trace(panel.sections[sectid])
|
|
||||||
-- render the panel again
|
|
||||||
panel:redraw(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
incoming_calls_handler = util.partial4(
|
|
||||||
hierarchy_handler,
|
|
||||||
'from',
|
|
||||||
call_hierarchy_handler_from,
|
|
||||||
gui.new_list_view,
|
|
||||||
' '
|
|
||||||
)
|
|
||||||
outgoing_calls_handler = util.partial4(hierarchy_handler, 'to', call_hierarchy_handler_to, gui.new_list_view, ' ')
|
|
||||||
|
|
||||||
local incoming_calls_panel = util.partial4(
|
local call_hierarchy_handler_from = partial(call_hierarchy_handler, "from")
|
||||||
hierarchy_handler,
|
local call_hierarchy_handler_to = partial(call_hierarchy_handler, "to")
|
||||||
'from',
|
|
||||||
call_hierarchy_handler_from,
|
|
||||||
display_panel,
|
|
||||||
' '
|
|
||||||
)
|
|
||||||
local outgoing_calls_panel = util.partial4(hierarchy_handler, 'to', call_hierarchy_handler_to, display_panel, ' ')
|
|
||||||
|
|
||||||
local incoming_calls_expand = util.partial4(hierarchy_handler, 'from', call_hierarchy_handler_from, expand_item, ' ')
|
local function incoming_calls_handler(bang, err, result, ctx, cfg)
|
||||||
local outgoing_calls_expand = util.partial4(hierarchy_handler, 'to', call_hierarchy_handler_to, expand_item, ' ')
|
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp hierarchy")
|
||||||
|
local results = call_hierarchy_handler_from(err, result, ctx, cfg, "Incoming calls not found")
|
||||||
|
|
||||||
function expand(panel, node)
|
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, "ft")
|
||||||
trace(panel, node)
|
gui.new_list_view({items = results, ft = ft, api = ' '})
|
||||||
local params = make_params(node.uri, {
|
|
||||||
line = node.range.start.line,
|
|
||||||
character = node.range.start.character,
|
|
||||||
})
|
|
||||||
local handler = incoming_calls_expand
|
|
||||||
if node.api == out_method then
|
|
||||||
handler = outgoing_calls_expand
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local bufnr = vim.uri_to_bufnr(node.uri)
|
local function outgoing_calls_handler(bang, err, result, ctx, cfg)
|
||||||
call_hierarchy(node.method, {
|
local results = call_hierarchy_handler_to(err, result, ctx, cfg, "Outgoing calls not found")
|
||||||
params = params,
|
|
||||||
panel = panel,
|
|
||||||
parent_node = node,
|
|
||||||
handler = handler,
|
|
||||||
bufnr = bufnr,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
local request = vim.lsp.buf_request
|
|
||||||
|
|
||||||
-- call_hierarchy with floating window
|
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, "ft")
|
||||||
call_hierarchy = function(method, opts)
|
gui.new_list_view({items = results, ft = ft, api = ' '})
|
||||||
trace(method, opts)
|
-- fzf_locations(bang, "", "Outgoing Calls", results, false)
|
||||||
opts = opts or {}
|
|
||||||
local params = opts.params or vim.lsp.util.make_position_params()
|
|
||||||
local bufnr = opts.bufnr
|
|
||||||
local handler = function(err, result, ctx, cfg)
|
|
||||||
ctx.opts = opts
|
|
||||||
return opts.handler(err, result, ctx, cfg)
|
|
||||||
end
|
end
|
||||||
-- log(opts, params)
|
|
||||||
return request(
|
function M.incoming_calls(bang, opts)
|
||||||
bufnr,
|
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp hierarchy")
|
||||||
'textDocument/prepareCallHierarchy',
|
if not lsphelper.check_capabilities("call_hierarchy") then
|
||||||
params,
|
|
||||||
vim.lsp.with(function(err, result, ctx)
|
|
||||||
if err then
|
|
||||||
vim.notify(err.message, vim.log.levels.WARN)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local call_hierarchy_item = pick_call_hierarchy_item(result)
|
|
||||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
|
||||||
if client then
|
|
||||||
trace('result', result, 'items', call_hierarchy_item, method, ctx, client.name)
|
|
||||||
client.request(method, {
|
|
||||||
item = call_hierarchy_item,
|
|
||||||
args = {
|
|
||||||
method = method,
|
|
||||||
},
|
|
||||||
}, handler, ctx.bufnr)
|
|
||||||
else
|
|
||||||
vim.notify(string.format('Client with id=%d stopped', ctx.client_id), vim.log.levels.WARN)
|
|
||||||
end
|
|
||||||
end, { direction = method, depth = opts.depth })
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.incoming_calls(opts)
|
local params = vim.lsp.util.make_position_params()
|
||||||
call_hierarchy(in_method, opts)
|
lsphelper.call_sync("callHierarchy/incomingCalls", params, opts, partial(incoming_calls_handler, bang))
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.outgoing_calls(opts)
|
function M.outgoing_calls(bang, opts)
|
||||||
call_hierarchy(out_method, opts)
|
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags")
|
||||||
|
if not lsphelper.check_capabilities("call_hierarchy") then
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.incoming_calls_panel(opts)
|
local params = vim.lsp.util.make_position_params()
|
||||||
opts = vim.tbl_extend('force', { handler = incoming_calls_panel }, opts or {})
|
lsphelper.call_sync("callHierarchy/outgoingCalls", params, opts, partial(outgoing_calls_handler, bang))
|
||||||
call_hierarchy(in_method, opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.outgoing_calls_panel(opts)
|
M.incoming_calls_call = partial(M.incoming_calls, 0)
|
||||||
opts = vim.tbl_extend('force', { handler = outgoing_calls_panel }, opts or {})
|
M.outgoing_calls_call = partial(M.outgoing_calls, 0)
|
||||||
call_hierarchy(out_method, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.incoming_calls_handler = incoming_calls_handler
|
M.incoming_calls_handler = partial(incoming_calls_handler, 0)
|
||||||
M.outgoing_calls_handler = outgoing_calls_handler
|
M.outgoing_calls_handler = partial(outgoing_calls_handler, 0)
|
||||||
-- for testing
|
|
||||||
M._call_hierarchy = call_hierarchy
|
|
||||||
|
|
||||||
function M.calltree(args)
|
|
||||||
if args == '-o' then
|
|
||||||
return M.outgoing_calls_panel()
|
|
||||||
end
|
|
||||||
M.incoming_calls_panel()
|
|
||||||
end
|
|
||||||
return M
|
return M
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,191 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
local vfn = vim.fn
|
|
||||||
M.defaults = function()
|
|
||||||
local has_lsp, lspconfig = pcall(require, 'lspconfig')
|
|
||||||
local highlight = require('navigator.lspclient.highlight')
|
|
||||||
if not has_lsp then
|
|
||||||
return {
|
|
||||||
setup = function()
|
|
||||||
vim.notify('loading lsp config failed LSP may not working correctly', vim.lsp.log_levels.WARN)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
local util = lspconfig.util
|
|
||||||
local on_attach = require('navigator.lspclient.attach').on_attach
|
|
||||||
|
|
||||||
|
|
||||||
local setups = {
|
|
||||||
clojure_lsp = {
|
|
||||||
root_dir = function(fname)
|
|
||||||
return util.root_pattern('deps.edn', 'build.boot', 'project.clj', 'shadow-cljs.edn', 'bb.edn', '.git')(fname)
|
|
||||||
or util.path.dirname(fname)
|
|
||||||
end,
|
|
||||||
on_attach = on_attach,
|
|
||||||
filetypes = { 'clojure', 'edn' },
|
|
||||||
message_level = vim.lsp.protocol.MessageType.error,
|
|
||||||
cmd = { 'clojure-lsp' },
|
|
||||||
},
|
|
||||||
|
|
||||||
elixirls = {
|
|
||||||
on_attach = on_attach,
|
|
||||||
filetypes = { 'elixir', 'eelixir' },
|
|
||||||
cmd = { 'elixir-ls' },
|
|
||||||
message_level = vim.lsp.protocol.MessageType.error,
|
|
||||||
settings = {
|
|
||||||
elixirLS = {
|
|
||||||
dialyzerEnabled = true,
|
|
||||||
fetchDeps = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
root_dir = function(fname)
|
|
||||||
return util.root_pattern('mix.exs', '.git')(fname) or util.path.dirname(fname)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
gopls = {
|
|
||||||
on_attach = on_attach,
|
|
||||||
-- capabilities = cap,
|
|
||||||
filetypes = { 'go', 'gomod', 'gohtmltmpl', 'gotexttmpl' },
|
|
||||||
message_level = vim.lsp.protocol.MessageType.Error,
|
|
||||||
cmd = {
|
|
||||||
'gopls', -- share the gopls instance if there is one already
|
|
||||||
'-remote=auto', --[[ debug options ]] --
|
|
||||||
-- "-logfile=auto",
|
|
||||||
-- "-debug=:0",
|
|
||||||
'-remote.debug=:0',
|
|
||||||
-- "-rpc.trace",
|
|
||||||
},
|
|
||||||
|
|
||||||
flags = { allow_incremental_sync = true, debounce_text_changes = 1000 },
|
|
||||||
settings = {
|
|
||||||
gopls = {
|
|
||||||
-- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
|
|
||||||
-- flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
||||||
-- not supported
|
|
||||||
analyses = { unusedparams = true, unreachable = false },
|
|
||||||
codelenses = {
|
|
||||||
generate = true, -- show the `go generate` lens.
|
|
||||||
gc_details = true, -- // Show a code lens toggling the display of gc's choices.
|
|
||||||
test = true,
|
|
||||||
tidy = true,
|
|
||||||
},
|
|
||||||
usePlaceholders = true,
|
|
||||||
completeUnimported = true,
|
|
||||||
staticcheck = true,
|
|
||||||
matcher = 'fuzzy',
|
|
||||||
diagnosticsDelay = '500ms',
|
|
||||||
experimentalWatchedFileDelay = '1000ms',
|
|
||||||
symbolMatcher = 'fuzzy',
|
|
||||||
gofumpt = false, -- true, -- turn on for new repos, gofmpt is good but also create code turmoils
|
|
||||||
buildFlags = { '-tags', 'integration' },
|
|
||||||
-- buildFlags = {"-tags", "functional"}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
root_dir = function(fname)
|
|
||||||
return util.root_pattern('go.mod', '.git')(fname) or dirname(fname) -- util.path.dirname(fname)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
clangd = {
|
|
||||||
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
||||||
cmd = {
|
|
||||||
'clangd',
|
|
||||||
'--background-index',
|
|
||||||
'--suggest-missing-includes',
|
|
||||||
'--clang-tidy',
|
|
||||||
'--header-insertion=iwyu',
|
|
||||||
'--clang-tidy-checks=-*,llvm-*,clang-analyzer-*',
|
|
||||||
'--cross-file-rename',
|
|
||||||
},
|
|
||||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
||||||
or true
|
|
||||||
on_attach(client, bufnr)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
rust_analyzer = {
|
|
||||||
root_dir = function(fname)
|
|
||||||
return util.root_pattern('Cargo.toml', 'rust-project.json', '.git')(fname) or util.path.dirname(fname)
|
|
||||||
end,
|
|
||||||
filetypes = { 'rust' },
|
|
||||||
message_level = vim.lsp.protocol.MessageType.error,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
['rust-analyzer'] = {
|
|
||||||
assist = { importMergeBehavior = 'last', importPrefix = 'by_self' },
|
|
||||||
cargo = { loadOutDirsFromCheck = true },
|
|
||||||
procMacro = { enable = true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
||||||
},
|
|
||||||
sqls = {
|
|
||||||
filetypes = { 'sql' },
|
|
||||||
on_attach = function(client, _)
|
|
||||||
client.server_capabilities.executeCommandProvider = client.server_capabilities.documentFormattingProvider
|
|
||||||
or true
|
|
||||||
highlight.diagnositc_config_sign()
|
|
||||||
require('sqls').setup({ picker = 'telescope' }) -- or default
|
|
||||||
end,
|
|
||||||
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
||||||
settings = {
|
|
||||||
cmd = { 'sqls', '-config', '$HOME/.config/sqls/config.yml' },
|
|
||||||
-- alterantively:
|
|
||||||
-- connections = {
|
|
||||||
-- {
|
|
||||||
-- driver = 'postgresql',
|
|
||||||
-- datasourcename = 'host=127.0.0.1 port=5432 user=postgres password=password dbname=user_db sslmode=disable',
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
pyright = {
|
|
||||||
on_attach = on_attach,
|
|
||||||
cmd = { 'pyright-langserver', '--stdio' },
|
|
||||||
filetypes = { 'python' },
|
|
||||||
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
||||||
settings = {
|
|
||||||
python = {
|
|
||||||
formatting = { provider = 'black' },
|
|
||||||
analysis = {
|
|
||||||
autoSearchPaths = true,
|
|
||||||
useLibraryCodeForTypes = true,
|
|
||||||
diagnosticMode = 'workspace',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ccls = {
|
|
||||||
on_attach = on_attach,
|
|
||||||
init_options = {
|
|
||||||
compilationDatabaseDirectory = 'build',
|
|
||||||
root_dir = [[ util.root_pattern("compile_commands.json", "compile_flags.txt", "CMakeLists.txt", "Makefile", ".git") or util.path.dirname ]],
|
|
||||||
index = { threads = 2 },
|
|
||||||
clang = { excludeArgs = { '-frounding-math' } },
|
|
||||||
},
|
|
||||||
flags = { allow_incremental_sync = true },
|
|
||||||
},
|
|
||||||
jdtls = {
|
|
||||||
settings = {
|
|
||||||
java = { signatureHelp = { enabled = true }, contentProvider = { preferred = 'fernflower' } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
omnisharp = {
|
|
||||||
cmd = { 'omnisharp', '--languageserver', '--hostPID', tostring(vfn.getpid()) },
|
|
||||||
},
|
|
||||||
terraformls = {
|
|
||||||
filetypes = { 'terraform', 'tf' },
|
|
||||||
},
|
|
||||||
|
|
||||||
sourcekit = {
|
|
||||||
cmd = { 'sourcekit-lsp' },
|
|
||||||
filetypes = { 'swift' }, -- This is recommended if you have separate settings for clangd.
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
setups.sumneko_lua = require('navigator.lspclient.sumneko_lua').sumneko_lua()
|
|
||||||
return setups
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,47 +0,0 @@
|
|||||||
return {
|
|
||||||
'angularls',
|
|
||||||
'gopls',
|
|
||||||
'tsserver',
|
|
||||||
'flow',
|
|
||||||
'bashls',
|
|
||||||
'dockerls',
|
|
||||||
'julials',
|
|
||||||
'pylsp',
|
|
||||||
'pyright',
|
|
||||||
'jedi_language_server',
|
|
||||||
'jdtls',
|
|
||||||
'sumneko_lua',
|
|
||||||
'vimls',
|
|
||||||
'html',
|
|
||||||
'jsonls',
|
|
||||||
'solargraph',
|
|
||||||
'cssls',
|
|
||||||
'yamlls',
|
|
||||||
'clangd',
|
|
||||||
'ccls',
|
|
||||||
'sqls',
|
|
||||||
'denols',
|
|
||||||
'graphql',
|
|
||||||
'dartls',
|
|
||||||
'dotls',
|
|
||||||
'kotlin_language_server',
|
|
||||||
'nimls',
|
|
||||||
'intelephense',
|
|
||||||
'vuels',
|
|
||||||
'volar',
|
|
||||||
'phpactor',
|
|
||||||
'omnisharp',
|
|
||||||
'r_language_server',
|
|
||||||
'rust_analyzer',
|
|
||||||
'terraformls',
|
|
||||||
'svelte',
|
|
||||||
'texlab',
|
|
||||||
'clojure_lsp',
|
|
||||||
'elixirls',
|
|
||||||
'sourcekit',
|
|
||||||
'fsautocomplete',
|
|
||||||
'vls',
|
|
||||||
'hls',
|
|
||||||
'tflint',
|
|
||||||
'terraform_lsp',
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
local vfn = vim.fn
|
|
||||||
|
|
||||||
local library = {}
|
|
||||||
local sumneko_cfg = {
|
|
||||||
cmd = { 'lua-language-server' },
|
|
||||||
filetypes = { 'lua' },
|
|
||||||
on_attach = on_attach,
|
|
||||||
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
||||||
version = 'LuaJIT',
|
|
||||||
},
|
|
||||||
diagnostics = {
|
|
||||||
enable = true,
|
|
||||||
-- Get the language server to recognize the `vim` global
|
|
||||||
globals = { 'vim', 'describe', 'it', 'before_each', 'after_each', 'teardown', 'pending' },
|
|
||||||
},
|
|
||||||
completion = { callSnippet = 'Both' },
|
|
||||||
workspace = {
|
|
||||||
-- Make the server aware of Neovim runtime files
|
|
||||||
library = library,
|
|
||||||
maxPreload = 2000,
|
|
||||||
preloadFileSize = 40000,
|
|
||||||
},
|
|
||||||
telemetry = { enable = false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
on_new_config = function(cfg, root)
|
|
||||||
local libs = vim.tbl_deep_extend('force', {}, library)
|
|
||||||
libs[root] = nil
|
|
||||||
cfg.settings.Lua.workspace.library = libs
|
|
||||||
return cfg
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
local function add(lib)
|
|
||||||
for _, p in pairs(vfn.expand(lib, false, true)) do
|
|
||||||
p = vim.loop.fs_realpath(p)
|
|
||||||
if p then
|
|
||||||
library[p] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function sumneko_lua()
|
|
||||||
-- add runtime
|
|
||||||
-- add plugins it may be very slow to add all in path
|
|
||||||
add('$VIMRUNTIME')
|
|
||||||
-- add your config
|
|
||||||
-- local home = vfn.expand("$HOME")
|
|
||||||
add(vfn.stdpath('config'))
|
|
||||||
|
|
||||||
library[vfn.expand('$VIMRUNTIME/lua')] = true
|
|
||||||
library[vfn.expand('$VIMRUNTIME/lua/vim')] = true
|
|
||||||
library[vfn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
|
|
||||||
|
|
||||||
local on_attach = require('navigator.lspclient.attach').on_attach
|
|
||||||
local luadevcfg = {
|
|
||||||
library = {
|
|
||||||
vimruntime = true, -- runtime path
|
|
||||||
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
|
||||||
plugins = { 'nvim-treesitter', 'plenary.nvim' },
|
|
||||||
},
|
|
||||||
lspconfig = {
|
|
||||||
-- cmd = {sumneko_binary},
|
|
||||||
on_attach = on_attach,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
local luadev = {}
|
|
||||||
local user_luadev = _NgConfigValues.lsp['lua-dev']
|
|
||||||
if user_luadev then
|
|
||||||
luadevcfg = vim.tbl_deep_extend('force', luadevcfg, user_luadev)
|
|
||||||
end
|
|
||||||
require('navigator.lazyloader').load('lua-dev.nvim', 'folke/lua-dev.nvim')
|
|
||||||
|
|
||||||
local ok, l = pcall(require, 'lua-dev')
|
|
||||||
if ok and l then
|
|
||||||
luadev = l.setup(luadevcfg)
|
|
||||||
end
|
|
||||||
|
|
||||||
sumneko_cfg = vim.tbl_deep_extend('force', sumneko_cfg, luadev)
|
|
||||||
return sumneko_cfg
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
sumneko_lua = sumneko_lua,
|
|
||||||
}
|
|
@ -1,16 +1,44 @@
|
|||||||
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/rename.lua
|
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/rename.lua
|
||||||
local M = {}
|
local M = {}
|
||||||
local util = require('navigator.util')
|
local util = require "navigator.util"
|
||||||
-- local rename_prompt = 'Rename -> '
|
local rename_prompt = "Rename -> "
|
||||||
|
|
||||||
M.rename = function()
|
M.rename = function()
|
||||||
local input = vim.ui.input
|
local current_name = vim.fn.expand("<cword>")
|
||||||
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.ui.input = require('guihua.floating').input
|
vim.api.nvim_buf_set_option(bufnr, "buftype", "prompt")
|
||||||
vim.lsp.buf.rename()
|
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
|
||||||
vim.defer_fn(function()
|
vim.api.nvim_buf_add_highlight(bufnr, -1, "NGPreviewTitle", 0, 0, #rename_prompt)
|
||||||
vim.ui.input = input
|
vim.fn.prompt_setprompt(bufnr, rename_prompt)
|
||||||
end, 1000)
|
local width = #current_name + #rename_prompt + 10
|
||||||
|
local winnr = vim.api.nvim_open_win(bufnr, true, {
|
||||||
|
relative = "cursor",
|
||||||
|
width = width,
|
||||||
|
height = 1,
|
||||||
|
row = -3,
|
||||||
|
col = 1,
|
||||||
|
style = "minimal",
|
||||||
|
border = "single"
|
||||||
|
})
|
||||||
|
vim.api.nvim_win_set_option(winnr, "winhl", "Normal:Floating")
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, "filetype", "guihua")
|
||||||
|
util.map("n", "<ESC>", "<cmd>bd!<CR>", {silent = true, buffer = true})
|
||||||
|
util.map({"n", "i"}, "<CR>", "<cmd>lua require('navigator.rename').callback()<CR>",
|
||||||
|
{silent = true, buffer = true})
|
||||||
|
util.map({"n", "i"}, "<BS>", [[<ESC>"_cl]], {silent = true, buffer = true})
|
||||||
|
vim.cmd(string.format("normal i%s", current_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.callback = function()
|
||||||
|
local new_name = vim.trim(vim.fn.getline("."):sub(#rename_prompt + 1, -1))
|
||||||
|
vim.cmd [[stopinsert]]
|
||||||
|
vim.cmd [[bd!]]
|
||||||
|
if #new_name == 0 or new_name == vim.fn.expand("<cword>") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local params = vim.lsp.util.make_position_params()
|
||||||
|
params.newName = new_name
|
||||||
|
vim.lsp.buf_request(0, "textDocument/rename", params)
|
||||||
|
end
|
||||||
|
-- M.callback()
|
||||||
return M
|
return M
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/rename.lua
|
|
||||||
local M = {}
|
|
||||||
local util = require('navigator.util')
|
|
||||||
local gutil = require('guihua.util')
|
|
||||||
local lsphelper = require('navigator.lspwrapper')
|
|
||||||
local symbols_to_items = lsphelper.symbols_to_items
|
|
||||||
local vfn = vim.fn
|
|
||||||
|
|
||||||
M.add_workspace_folder = function()
|
|
||||||
util.log(vim.ui.input)
|
|
||||||
local input = require('guihua.floating').input
|
|
||||||
input({ prompt = 'Workspace To Add: ', default = vfn.expand('%:p:h') }, function(inputs)
|
|
||||||
vim.lsp.buf.add_workspace_folder(inputs)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.remove_workspace_folder = function()
|
|
||||||
local select = require('guihua.gui').select
|
|
||||||
local folders = vim.lsp.buf.list_workspace_folders()
|
|
||||||
|
|
||||||
if #folders > 1 then
|
|
||||||
return select(folders, { prompt = 'select workspace to delete' }, function(workspace)
|
|
||||||
vim.lsp.buf.remove_workspace_folder(workspace)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
M.workspace_symbol = function()
|
|
||||||
local input = require('guihua.floating').input
|
|
||||||
input({ prompt = 'Search symbol: ', default = '' }, function(inputs)
|
|
||||||
util.log(inputs)
|
|
||||||
vim.lsp.buf.workspace_symbol(inputs)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.workspace_symbol_live()
|
|
||||||
local height = _NgConfigValues.height or 0.4
|
|
||||||
height = math.floor(height * vfn.winheight('%'))
|
|
||||||
local width = _NgConfigValues.width or 0.7
|
|
||||||
width = math.floor(vim.api.nvim_get_option('columns') * width)
|
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
|
||||||
local ft = vim.o.ft
|
|
||||||
local data = { { text = 'input the symbol name to start fuzzy search' } }
|
|
||||||
for _ = 1, height do
|
|
||||||
table.insert(data, { text = '' })
|
|
||||||
end
|
|
||||||
local ListView = require('guihua.listview')
|
|
||||||
local opt = {
|
|
||||||
api = ' ',
|
|
||||||
bg = 'GuihuaListDark',
|
|
||||||
data = data,
|
|
||||||
items = data,
|
|
||||||
enter = true,
|
|
||||||
ft = ft,
|
|
||||||
loc = 'top_center',
|
|
||||||
transparency = 50,
|
|
||||||
prompt = true,
|
|
||||||
on_confirm = function(item)
|
|
||||||
vim.defer_fn(function()
|
|
||||||
if item and item.name then
|
|
||||||
require('navigator.symbols').workspace_symbols(item.name)
|
|
||||||
end
|
|
||||||
end, 10)
|
|
||||||
end,
|
|
||||||
on_input_filter = function(text)
|
|
||||||
local params = { query = text or '#' }
|
|
||||||
local results = vim.lsp.buf_request_sync(bufnr, 'workspace/symbol', params)
|
|
||||||
local result
|
|
||||||
for _, r in pairs(results) do
|
|
||||||
-- util.log(r)
|
|
||||||
if r.result then
|
|
||||||
result = r.result
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not result then
|
|
||||||
result = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
local items = symbols_to_items(result)
|
|
||||||
items = gutil.dedup(items, 'name', 'kind')
|
|
||||||
return items
|
|
||||||
end,
|
|
||||||
rect = { height = height, pos_x = 0, pos_y = 0, width = width },
|
|
||||||
}
|
|
||||||
|
|
||||||
local win = ListView:new(opt)
|
|
||||||
win:on_draw({})
|
|
||||||
-- require('guihua.gui').new_list_view(opt)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.list_workspace_folders = function()
|
|
||||||
local folders = vim.lsp.buf.list_workspace_folders()
|
|
||||||
if #folders > 0 then
|
|
||||||
return require('navigator.gui').new_list_view({
|
|
||||||
items = folders,
|
|
||||||
border = 'single',
|
|
||||||
rawdata = true,
|
|
||||||
on_move = function() end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,38 +0,0 @@
|
|||||||
# Sandbox/Tutorial
|
|
||||||
|
|
||||||
## introduction
|
|
||||||
|
|
||||||
The folder contains `init.lua`, whitch is a minium vimrc to setup following plugins. Those plugin are some of the
|
|
||||||
most used plugins for programmer.
|
|
||||||
|
|
||||||
- lspconfig
|
|
||||||
- treesitter
|
|
||||||
- navigator
|
|
||||||
- nvim-cmp
|
|
||||||
- luasnip
|
|
||||||
- aurora (colorscheme used in the screenshot)
|
|
||||||
|
|
||||||
There are three folders `js`, `go`, `py`. Those folders have some basic source code you can play with.
|
|
||||||
The init will install the plugins in ``/tmp/nvim`` folder. It will not affect your current setup.
|
|
||||||
|
|
||||||
## Install LSP
|
|
||||||
|
|
||||||
The playground has js, py, go folder, so you can install either one your self in your PATH.
|
|
||||||
If you want to try lua, Please check sumneko setup in init.lua make sure it pointed to correct path. By default it
|
|
||||||
potint to ~/github/sumneko if not existed in your PATH.
|
|
||||||
|
|
||||||
## run init.lua
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd py
|
|
||||||
neovim -u init.lua
|
|
||||||
```
|
|
||||||
|
|
||||||
Move your cursor around and try to
|
|
||||||
|
|
||||||
- Edit the code
|
|
||||||
- Check symbol reference with `<esc>gr`
|
|
||||||
- Check document symbol with `<esc>g0`
|
|
||||||
- treesitter symbole `<esc>gT`
|
|
||||||
- peek definition `<esc>gp`
|
|
||||||
- ...
|
|
@ -1,8 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
func Fib(n int) int {
|
|
||||||
if n < 2 {
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
return Fib(n-1) + Fib(n-2)
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestFib(t *testing.T) {
|
|
||||||
require.NoError(t, nil)
|
|
||||||
d := Fib(1)
|
|
||||||
fmt.Println(d)
|
|
||||||
if d != 1 {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
// "net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Dog struct {
|
|
||||||
name string
|
|
||||||
age int
|
|
||||||
owner string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDog(name string, age int) *Dog {
|
|
||||||
return &Dog{name: name, age: age}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetOwner
|
|
||||||
func (d *Dog) SetOwner(owner string) {
|
|
||||||
d.owner = owner
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDogName
|
|
||||||
func (d *Dog) SetDogName(name string) {
|
|
||||||
if d == nil {
|
|
||||||
d = NewDog(name, 0)
|
|
||||||
d.name = name
|
|
||||||
} else {
|
|
||||||
d.name = name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Dog) SetOwnerUtf8(name []byte) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func fun1() {
|
|
||||||
}
|
|
||||||
|
|
||||||
func fun1_test() {
|
|
||||||
d := NewDog("", 1)
|
|
||||||
NewDog("abc", 12)
|
|
||||||
// fmt.Printf("abc", 1)
|
|
||||||
time.Date(12, 12, 12, 33, 12, 55, 22, nil)
|
|
||||||
|
|
||||||
d.SetOwnerUtf8([]byte{1})
|
|
||||||
w := httptest.NewRecorder()
|
|
||||||
w.Write([]byte{})
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDog(t *testing.T) {
|
|
||||||
require.NoError(t, nil)
|
|
||||||
d := NewDog("Fibi", 4)
|
|
||||||
fmt.Println(d.name)
|
|
||||||
if d.name != "Fibi" {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCat(t *testing.T) {
|
|
||||||
d := NewDog("Fibi cat", 4)
|
|
||||||
fmt.Println(d.name)
|
|
||||||
if d.name != "Fibi cat" {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCow(t *testing.T) {
|
|
||||||
require.NoError(t, nil)
|
|
||||||
d := NewDog("Fibi", 4)
|
|
||||||
fmt.Println(d.name)
|
|
||||||
if d.name != "Fibi" {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHorse(t *testing.T) {
|
|
||||||
d := NewDog("Fibi cat", 4)
|
|
||||||
fmt.Println(d.name)
|
|
||||||
if d.name != "Fibi cat" {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"math"
|
|
||||||
//"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
type geometry interface {
|
|
||||||
area() float64
|
|
||||||
perim() float64
|
|
||||||
}
|
|
||||||
|
|
||||||
type rect struct {
|
|
||||||
width float64 `-line:"width"`
|
|
||||||
height float64 `-line:"height"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type rect2 struct {
|
|
||||||
width int `yml:"width"`
|
|
||||||
height int `yml:"height"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r rect) area() float64 {
|
|
||||||
return r.width * r.height
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r rect) perim() float64 {
|
|
||||||
return 2*r.width + 2*r.height
|
|
||||||
}
|
|
||||||
|
|
||||||
type circle struct {
|
|
||||||
radius float64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c circle) area() float64 {
|
|
||||||
return math.Pi * c.radius * c.radius
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c circle) perim() float64 {
|
|
||||||
return 2 * math.Pi * c.radius
|
|
||||||
}
|
|
||||||
|
|
||||||
func measure(g geometry) int {
|
|
||||||
fmt.Println(g)
|
|
||||||
fmt.Println(g.area())
|
|
||||||
fmt.Println(g.perim())
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func m2() {
|
|
||||||
measure(rect{width: 3})
|
|
||||||
}
|
|
||||||
|
|
||||||
func M2() {
|
|
||||||
measure(rect{width: 3})
|
|
||||||
}
|
|
||||||
|
|
||||||
func interfaceTest() {
|
|
||||||
r := rect{width: 3, height: 4}
|
|
||||||
c := circle{radius: 5}
|
|
||||||
measure(r)
|
|
||||||
measure(c)
|
|
||||||
d := circle{radius: 10}
|
|
||||||
fmt.Println()
|
|
||||||
fun2(d)
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io/fs"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// main
|
|
||||||
// note: this is main func
|
|
||||||
func main() {
|
|
||||||
i := 32
|
|
||||||
i = i + 1
|
|
||||||
fmt.Println("hello, world", i)
|
|
||||||
var uns1 unsafe.Pointer
|
|
||||||
|
|
||||||
var x struct {
|
|
||||||
a int64
|
|
||||||
b bool
|
|
||||||
c string
|
|
||||||
}
|
|
||||||
const M, N = unsafe.Sizeof(x.c), unsafe.Sizeof(x)
|
|
||||||
fmt.Println(M, N, uns1) // 16 32
|
|
||||||
|
|
||||||
var perr *fs.PathError
|
|
||||||
if errors.As(nil, &perr) {
|
|
||||||
fmt.Println(perr.Path)
|
|
||||||
}
|
|
||||||
myfunc3("a", "b")
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// import "fmt"
|
|
||||||
|
|
||||||
type person struct {
|
|
||||||
name string
|
|
||||||
age int
|
|
||||||
}
|
|
||||||
|
|
||||||
type say interface {
|
|
||||||
hello() string
|
|
||||||
}
|
|
||||||
|
|
||||||
type strudent struct {
|
|
||||||
person struct {
|
|
||||||
name string
|
|
||||||
age int
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newPerson(name string) *person {
|
|
||||||
p := person{name: name}
|
|
||||||
fmt.Println("")
|
|
||||||
p.age = 42
|
|
||||||
return &p
|
|
||||||
}
|
|
||||||
|
|
||||||
func newPerson2(name, say string) {
|
|
||||||
fmt.Println(name, say)
|
|
||||||
}
|
|
||||||
|
|
||||||
func b() {
|
|
||||||
newPerson2("a", "say")
|
|
||||||
|
|
||||||
ret := measure(rect{width: 3})
|
|
||||||
fmt.Println(ret)
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package test
|
|
||||||
|
|
||||||
type Dog struct {
|
|
||||||
name string
|
|
||||||
age int
|
|
||||||
owner string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDog(name string, age int) *Dog {
|
|
||||||
return &Dog{name: name, age: age}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetOwner
|
|
||||||
func (d *Dog) SetOwner(owner string) {
|
|
||||||
d.owner = owner
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetName
|
|
||||||
func (d *Dog) SetName(name string) {
|
|
||||||
if d == nil {
|
|
||||||
d = NewDog(name, 0)
|
|
||||||
d.name = name
|
|
||||||
} else {
|
|
||||||
d.name = name
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package tekkkt
|
|
||||||
|
|
||||||
type Dog kkktruct {
|
|
||||||
name kkktring
|
|
||||||
age int
|
|
||||||
owner kkktring
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDog(name kkktring, age int) *Dog {
|
|
||||||
return &Dog{name: name, age: age}
|
|
||||||
}
|
|
||||||
|
|
||||||
// kkketOwner
|
|
||||||
func (d *Dog) kkketOwner(owner kkktring) {
|
|
||||||
d.owner = owner
|
|
||||||
}
|
|
||||||
|
|
||||||
// kkketName
|
|
||||||
func (d *Dog) kkketName(name kkktring) {
|
|
||||||
if d == nil {
|
|
||||||
d = NewDog(name, 0)
|
|
||||||
d.name = name
|
|
||||||
} elkkke {
|
|
||||||
d.name = name
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDog(t *testing.T) {
|
|
||||||
d := NewDog("Fibi", 4)
|
|
||||||
fmt.Println(d.name)
|
|
||||||
if d.name != "Fibi" {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCat(t *testing.T) {
|
|
||||||
d := NewDog("Fibi cat", 4)
|
|
||||||
fmt.Println(d.name)
|
|
||||||
if d.name != "Fibi cat" {
|
|
||||||
t.Errorf("NewDog failled %v", d)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
// "strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
// type Name2 struct {
|
|
||||||
// f1 string
|
|
||||||
// f2 int
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// type name4 struct {
|
|
||||||
// f1 string
|
|
||||||
// f2 int
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// type name5 struct {
|
|
||||||
// f1 string
|
|
||||||
// f2 int
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func test2() {
|
|
||||||
// type some struct {
|
|
||||||
// Success bool `-line:"success"`
|
|
||||||
// Failure bool
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // myfunc("aaa", "bbb")
|
|
||||||
// }
|
|
||||||
|
|
||||||
func myfunc3(v, v2 string) error {
|
|
||||||
time.After(time.Hour)
|
|
||||||
fmt.Println(v, v2)
|
|
||||||
// fmt.Println(kk)
|
|
||||||
//
|
|
||||||
|
|
||||||
time.Date(2020, 12, 11, 21, 11, 44, 12, nil)
|
|
||||||
time.Date(2020, 1, 11, 11, 11, 2, 1, nil)
|
|
||||||
time.Date(1111, 22, 11, 1, 1, 1, 1, nil)
|
|
||||||
time.Date(12345, 2333, 444, 555, 66, 1, 22, nil)
|
|
||||||
fmt.Println(`kkkkkk`)
|
|
||||||
log.Info(`abc`)
|
|
||||||
log.Infof(`log %s`, `def`)
|
|
||||||
log.Infof(`log %d`, 33)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// func myfunc4() {
|
|
||||||
// // myfunc("aaa", "bbb") // time.Date(12,11, )
|
|
||||||
// // myfunc("abc", "def")
|
|
||||||
// // myfunc("1", "2")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func mytest2() {
|
|
||||||
// i := 1
|
|
||||||
// log.Infof("%d", i)
|
|
||||||
// myfunc4()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func myfunc5() {
|
|
||||||
// hellostring := "hello"
|
|
||||||
// if strings.Contains(hellostring, "hello") {
|
|
||||||
// fmt.Println("it is there")
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -1,132 +0,0 @@
|
|||||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
|
||||||
vim.cmd([[set packpath=/tmp/nvim/site]])
|
|
||||||
|
|
||||||
local package_root = '/tmp/nvim/site/pack'
|
|
||||||
local install_path = package_root .. '/packer/start/packer.nvim'
|
|
||||||
|
|
||||||
-- IMPORTANT: update the sumneko setup if you need lua language server
|
|
||||||
-- I installed it in '/github/sumneko/lua-language-server'
|
|
||||||
local sumneko_root_path = vim.fn.expand('$HOME') .. '/github/sumneko/lua-language-server'
|
|
||||||
local sumneko_binary = vim.fn.expand('$HOME') .. '/github/sumneko/lua-language-server/bin/macOS/lua-language-server'
|
|
||||||
|
|
||||||
local lua_cfg = {
|
|
||||||
-- cmd = { sumneko_binary, '-E', sumneko_root_path .. '/main.lua' },
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') },
|
|
||||||
diagnostics = { enable = true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if vim.fn.executable('lua-language-server') == 0 then
|
|
||||||
lua_cfg.cmd = { sumneko_binary, '-E', sumneko_root_path .. '/main.lua' }
|
|
||||||
end
|
|
||||||
|
|
||||||
local function load_plugins()
|
|
||||||
require('packer').startup({
|
|
||||||
function(use)
|
|
||||||
use({ 'wbthomason/packer.nvim' })
|
|
||||||
use({
|
|
||||||
'nvim-treesitter/nvim-treesitter',
|
|
||||||
config = function()
|
|
||||||
require('nvim-treesitter.configs').setup({
|
|
||||||
ensure_installed = { 'python', 'go', 'javascript' },
|
|
||||||
highlight = { enable = true },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
run = ':TSUpdate',
|
|
||||||
})
|
|
||||||
use({ 'neovim/nvim-lspconfig' })
|
|
||||||
use({ 'ray-x/lsp_signature.nvim' })
|
|
||||||
use({ 'ray-x/aurora' })
|
|
||||||
use({
|
|
||||||
-- 'ray-x/navigator.lua',
|
|
||||||
'~/github/ray-x/navigator.lua',
|
|
||||||
requires = { 'ray-x/guihua.lua', run = 'cd lua/fzy && make' },
|
|
||||||
config = function()
|
|
||||||
require('navigator').setup({
|
|
||||||
debug = true,
|
|
||||||
keymaps = {
|
|
||||||
{ key = 'gK', func = vim.lsp.buf.definition, doc = 'definition' },
|
|
||||||
{
|
|
||||||
key = '<leader>ld',
|
|
||||||
func = require('navigator.diagnostics').show_buf_diagnostics,
|
|
||||||
desc = 'show_buf_diagnostics',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
icons = {
|
|
||||||
diagnostic_virtual_text = '',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use({ 'L3MON4D3/LuaSnip' })
|
|
||||||
use({
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
requires = {
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
local luasnip = require('luasnip')
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
mapping = {
|
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.confirm({ select = true })
|
|
||||||
elseif luasnip.expand_or_locally_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
},
|
|
||||||
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require('cmp').setup.cmdline(':', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'cmdline' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require('cmp').setup.cmdline('/', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
config = {
|
|
||||||
package_root = package_root,
|
|
||||||
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.isdirectory(install_path) == 0 then
|
|
||||||
vim.fn.system({
|
|
||||||
'git',
|
|
||||||
'clone',
|
|
||||||
'https://github.com/wbthomason/packer.nvim',
|
|
||||||
install_path,
|
|
||||||
})
|
|
||||||
load_plugins()
|
|
||||||
require('packer').sync()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
else
|
|
||||||
load_plugins()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
end
|
|
@ -1,61 +0,0 @@
|
|||||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
|
||||||
vim.cmd([[set packpath=/tmp/nvim/site]])
|
|
||||||
|
|
||||||
local package_root = '/tmp/nvim/site/pack'
|
|
||||||
local install_path = package_root .. '/packer/start/packer.nvim'
|
|
||||||
vim.g.coq_settings = {
|
|
||||||
['auto_start'] = 'shut-up',
|
|
||||||
}
|
|
||||||
|
|
||||||
local function load_plugins()
|
|
||||||
require('packer').startup({
|
|
||||||
function(use)
|
|
||||||
use('wbthomason/packer.nvim')
|
|
||||||
use('neovim/nvim-lspconfig')
|
|
||||||
use({
|
|
||||||
'williamboman/nvim-lsp-installer',
|
|
||||||
config = function()
|
|
||||||
local lsp_installer = require('nvim-lsp-installer')
|
|
||||||
lsp_installer.setup{}
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use({
|
|
||||||
'ray-x/navigator.lua',
|
|
||||||
config = function()
|
|
||||||
require('navigator').setup({
|
|
||||||
debug = true,
|
|
||||||
lsp_installer = true,
|
|
||||||
keymaps = { { key = 'gR', func = "require('navigator.reference').async_ref()" } },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use('ray-x/guihua.lua')
|
|
||||||
-- -- COQ (Autocompletion)
|
|
||||||
use('ms-jpq/coq_nvim')
|
|
||||||
use('ms-jpq/coq.artifacts')
|
|
||||||
use('ms-jpq/coq.thirdparty')
|
|
||||||
use('ray-x/aurora')
|
|
||||||
end,
|
|
||||||
config = {
|
|
||||||
package_root = package_root,
|
|
||||||
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
-- navigator/LSP setup
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.isdirectory(install_path) == 0 then
|
|
||||||
print('install packer')
|
|
||||||
vim.fn.system({
|
|
||||||
'git',
|
|
||||||
'clone',
|
|
||||||
'https://github.com/wbthomason/packer.nvim',
|
|
||||||
install_path,
|
|
||||||
})
|
|
||||||
load_plugins()
|
|
||||||
require('packer').sync()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
else
|
|
||||||
load_plugins()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
end
|
|
@ -1,79 +0,0 @@
|
|||||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
|
||||||
vim.cmd([[set packpath=/tmp/nvim/site]])
|
|
||||||
|
|
||||||
local package_root = '/tmp/nvim/site/pack'
|
|
||||||
local install_path = package_root .. '/packer/start/packer.nvim'
|
|
||||||
|
|
||||||
local function load_plugins()
|
|
||||||
require('packer').startup({
|
|
||||||
function(use)
|
|
||||||
use('wbthomason/packer.nvim')
|
|
||||||
use('neovim/nvim-lspconfig')
|
|
||||||
use({
|
|
||||||
'williamboman/nvim-lsp-installer',
|
|
||||||
config = function()
|
|
||||||
require('nvim-lsp-installer').setup({})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use({
|
|
||||||
'ray-x/navigator.lua',
|
|
||||||
-- '~/github/ray-x/navigator.lua',
|
|
||||||
config = function()
|
|
||||||
require('navigator').setup({
|
|
||||||
debug = true,
|
|
||||||
lsp_installer = true,
|
|
||||||
keymaps = { { key = 'gR', func = "require('navigator.reference').async_ref()" } },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use('ray-x/guihua.lua')
|
|
||||||
|
|
||||||
use({
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
requires = {
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
cmp.setup({
|
|
||||||
mapping = {
|
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.confirm({ select = true })
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use('ray-x/aurora')
|
|
||||||
end,
|
|
||||||
config = {
|
|
||||||
package_root = package_root,
|
|
||||||
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
-- navigator/LSP setup
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.isdirectory(install_path) == 0 then
|
|
||||||
print('install packer')
|
|
||||||
vim.fn.system({
|
|
||||||
'git',
|
|
||||||
'clone',
|
|
||||||
'https://github.com/wbthomason/packer.nvim',
|
|
||||||
install_path,
|
|
||||||
})
|
|
||||||
load_plugins()
|
|
||||||
require('packer').sync()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
else
|
|
||||||
load_plugins()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
end
|
|
@ -1,7 +0,0 @@
|
|||||||
const sayHiToSomeone = (callback) => {
|
|
||||||
return callbcak();
|
|
||||||
};
|
|
||||||
|
|
||||||
sayHiToSomeone(()=> {
|
|
||||||
console.log("aaa")
|
|
||||||
})
|
|
@ -1,12 +0,0 @@
|
|||||||
function makeFunc() {
|
|
||||||
var browser = 'Mozilla';
|
|
||||||
function displayName() {
|
|
||||||
alert(browser);
|
|
||||||
var message = 'hello ' + browser;
|
|
||||||
alert(message);
|
|
||||||
}
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
var myFunc = makeFunc();
|
|
||||||
myFunc();
|
|
@ -1,11 +0,0 @@
|
|||||||
function curriedDot(vector1) {
|
|
||||||
return function(vector2) {
|
|
||||||
return vector1.reduce(
|
|
||||||
(sum, element, index) => (sum += element * vector2[index]),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const sumElements = curriedDot([1, 1, 1]);
|
|
||||||
console.log()
|
|
@ -1 +0,0 @@
|
|||||||
const time = new Date(12, 33, )
|
|
@ -1,3 +0,0 @@
|
|||||||
console.log("abc");
|
|
||||||
var kingsglove = "abcdefg";
|
|
||||||
console.log()
|
|
@ -1,14 +0,0 @@
|
|||||||
from random import shuffle
|
|
||||||
a = list(range(5))
|
|
||||||
|
|
||||||
def go(beg, c, b):
|
|
||||||
if beg >= len(a):
|
|
||||||
print(a )
|
|
||||||
for i in range(beg, len(a)):
|
|
||||||
a[beg], a[i] = a[i], a[beg]
|
|
||||||
go(beg + 1)
|
|
||||||
a[beg], a[i] = a[i], a[beg]
|
|
||||||
print(a, b)
|
|
||||||
|
|
||||||
go(0, 1, 4)
|
|
||||||
shuffle([1, 2,3 ])
|
|
@ -1,79 +0,0 @@
|
|||||||
import math
|
|
||||||
import numpy as np
|
|
||||||
import os
|
|
||||||
|
|
||||||
class Dog:
|
|
||||||
def __init__(self, name):
|
|
||||||
self.name = name
|
|
||||||
self.tricks = [] # creates a new empty list for each dog
|
|
||||||
|
|
||||||
def add_trick(self, trick):
|
|
||||||
self.tricks.append(trick)
|
|
||||||
|
|
||||||
|
|
||||||
d = Dog('Fido')
|
|
||||||
d.add_trick('roll over')
|
|
||||||
print(d.tricks)
|
|
||||||
|
|
||||||
def test_func():
|
|
||||||
k = [1, 2, 3]
|
|
||||||
sum = 0
|
|
||||||
for i in range(k, 1, 2):
|
|
||||||
sum += 1
|
|
||||||
print(sum)
|
|
||||||
|
|
||||||
def greet(greeting, name):
|
|
||||||
"""
|
|
||||||
This function greets to
|
|
||||||
the person passed in as
|
|
||||||
a parameter
|
|
||||||
"""
|
|
||||||
print(greeting + name + ". Good morning!")
|
|
||||||
|
|
||||||
|
|
||||||
# def greet(greeting, name, msg1, msg2):
|
|
||||||
# """
|
|
||||||
# This function greets to
|
|
||||||
# the person passed in as
|
|
||||||
# a parameter
|
|
||||||
# """
|
|
||||||
# print(greeting + name + ". Good morning!")
|
|
||||||
|
|
||||||
|
|
||||||
greet("a", "b")
|
|
||||||
|
|
||||||
|
|
||||||
def greet2():
|
|
||||||
print("whatever")
|
|
||||||
|
|
||||||
|
|
||||||
def greet3(name):
|
|
||||||
greet2()
|
|
||||||
greet("hey", "dude", "", "")
|
|
||||||
print("whatever" + name)
|
|
||||||
|
|
||||||
def greet3():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
greet2()
|
|
||||||
|
|
||||||
greet("name", "name")
|
|
||||||
|
|
||||||
greet3("name")
|
|
||||||
greet3("")
|
|
||||||
|
|
||||||
greet("1", "2")
|
|
||||||
|
|
||||||
|
|
||||||
def greeting(greet: int, *, g):
|
|
||||||
"""
|
|
||||||
This function greets to
|
|
||||||
the person passed in as
|
|
||||||
a parameter
|
|
||||||
"""
|
|
||||||
print(greet + g + ". Good morning!")
|
|
||||||
|
|
||||||
|
|
||||||
np.empty(1, order="F")
|
|
||||||
np.empty(1, order="F")
|
|
@ -1,19 +0,0 @@
|
|||||||
import pandas as pd
|
|
||||||
import io
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pow()
|
|
||||||
|
|
||||||
|
|
||||||
arg = 111
|
|
||||||
bufio = io
|
|
||||||
filename = 'my_excel.xls'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
df = pd.read_excel(abc, defgh)
|
|
@ -1,6 +0,0 @@
|
|||||||
std="lua52+vim"
|
|
||||||
|
|
||||||
[rules]
|
|
||||||
global_usage = "allow"
|
|
||||||
multiple_statements = "allow"
|
|
||||||
unused_variable = "allow"
|
|
@ -1,4 +0,0 @@
|
|||||||
indent_type = "Spaces"
|
|
||||||
indent_width = 2
|
|
||||||
column_width = 120
|
|
||||||
quote_style = "AutoPreferSingle"
|
|
@ -1,69 +0,0 @@
|
|||||||
local busted = require('plenary/busted')
|
|
||||||
|
|
||||||
local eq = assert.are.same
|
|
||||||
local cur_dir = vim.fn.expand('%:p:h')
|
|
||||||
-- local status = require("plenary.reload").reload_module("go.nvim")
|
|
||||||
-- status = require("plenary.reload").reload_module("nvim-treesitter")
|
|
||||||
|
|
||||||
-- local ulog = require('go.utils').log
|
|
||||||
describe('should run lsp call hierarchy', function()
|
|
||||||
vim.cmd([[packadd navigator.lua]])
|
|
||||||
vim.cmd([[packadd guihua.lua]])
|
|
||||||
local status = require('plenary.reload').reload_module('navigator')
|
|
||||||
status = require('plenary.reload').reload_module('guihua')
|
|
||||||
status = require('plenary.reload').reload_module('lspconfig')
|
|
||||||
|
|
||||||
local path = cur_dir .. '/tests/fixtures/interface.go' -- %:p:h ? %:p
|
|
||||||
local cmd = " silent exe 'e " .. path .. "'"
|
|
||||||
vim.cmd(cmd)
|
|
||||||
vim.cmd([[cd %:p:h]])
|
|
||||||
local bufn = vim.fn.bufnr('')
|
|
||||||
require('navigator').setup({
|
|
||||||
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
|
|
||||||
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
|
|
||||||
height = 0.3, -- max list window height, 0.3 by default
|
|
||||||
preview_height = 0.35, -- max height of preview windows
|
|
||||||
border = 'none',
|
|
||||||
})
|
|
||||||
|
|
||||||
-- allow gopls start
|
|
||||||
for _ = 1, 20 do
|
|
||||||
vim.wait(400, function() end)
|
|
||||||
local found = false
|
|
||||||
for _, client in ipairs(vim.lsp.get_active_clients()) do
|
|
||||||
if client.name == 'gopls' then
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if found then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it('should show panel', function()
|
|
||||||
vim.fn.setpos('.', { bufn, 24, 15, 0 })
|
|
||||||
require('navigator.hierarchy').incoming_calls_panel()
|
|
||||||
|
|
||||||
vim.wait(300, function() end)
|
|
||||||
|
|
||||||
local panel = require('guihua.panel').debug()
|
|
||||||
eq(panel.name, 'Panel')
|
|
||||||
|
|
||||||
vim.wait(500, function() end)
|
|
||||||
panel = require('guihua.panel').debug()
|
|
||||||
print(vim.inspect(panel))
|
|
||||||
-- eq(
|
|
||||||
-- panel.activePanel.sections[1].header[1],
|
|
||||||
-- '──────────Call Hierarchy──────────'
|
|
||||||
-- )
|
|
||||||
-- eq(panel.activePanel.sections[1].nodes[1].name, 'measure')
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('should not crash and show hierarchy', function()
|
|
||||||
vim.fn.setpos('.', { bufn, 24, 15, 0 })
|
|
||||||
local ret = require('navigator.hierarchy')._call_hierarchy()
|
|
||||||
vim.wait(400, function() end)
|
|
||||||
eq(ret, ret) -- make sure doesn't crash the result
|
|
||||||
end)
|
|
||||||
end)
|
|
@ -1,217 +0,0 @@
|
|||||||
local golden_result = {
|
|
||||||
{
|
|
||||||
col = 9,
|
|
||||||
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
full_text = 'package main',
|
|
||||||
kind = '🚀',
|
|
||||||
lnum = 1,
|
|
||||||
node_scope = {
|
|
||||||
['end'] = {
|
|
||||||
character = 0,
|
|
||||||
line = 12,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 0,
|
|
||||||
line = 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
node_text = 'main',
|
|
||||||
indent = '',
|
|
||||||
range = {
|
|
||||||
['end'] = {
|
|
||||||
character = 12,
|
|
||||||
line = 0,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 8,
|
|
||||||
line = 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
text = ' 🚀 main \t package main',
|
|
||||||
type = 'namespace',
|
|
||||||
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
col = 6,
|
|
||||||
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
full_text = 'func interfaceTest()',
|
|
||||||
kind = ' ',
|
|
||||||
lnum = 5,
|
|
||||||
indent = '',
|
|
||||||
node_scope = {
|
|
||||||
['end'] = {
|
|
||||||
character = 1,
|
|
||||||
line = 11,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 0,
|
|
||||||
line = 4,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
node_text = 'interfaceTest',
|
|
||||||
range = {
|
|
||||||
['end'] = {
|
|
||||||
character = 18,
|
|
||||||
line = 4,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 5,
|
|
||||||
line = 4,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
text = ' interfaceTest\t func interfaceTest()',
|
|
||||||
type = 'function',
|
|
||||||
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
col = 2,
|
|
||||||
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
full_text = 'r := rect{width: 3, height: 4}',
|
|
||||||
kind = ' ',
|
|
||||||
lnum = 6,
|
|
||||||
node_scope = {
|
|
||||||
['end'] = {
|
|
||||||
character = 1,
|
|
||||||
line = 11,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 21,
|
|
||||||
line = 4,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
indent = ' ',
|
|
||||||
node_text = 'r',
|
|
||||||
range = {
|
|
||||||
['end'] = {
|
|
||||||
character = 2,
|
|
||||||
line = 5,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 1,
|
|
||||||
line = 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
text = ' r \t r := rect{width: 3, height: 4}',
|
|
||||||
type = 'var',
|
|
||||||
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
col = 2,
|
|
||||||
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
full_text = 'c := circle{radius: 5}',
|
|
||||||
kind = ' ',
|
|
||||||
lnum = 7,
|
|
||||||
node_scope = {
|
|
||||||
['end'] = {
|
|
||||||
character = 1,
|
|
||||||
line = 11,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 21,
|
|
||||||
line = 4,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
node_text = 'c',
|
|
||||||
indent = ' ',
|
|
||||||
range = {
|
|
||||||
['end'] = {
|
|
||||||
character = 2,
|
|
||||||
line = 6,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 1,
|
|
||||||
line = 6,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
text = ' c \t c := circle{radius: 5}',
|
|
||||||
type = 'var',
|
|
||||||
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
col = 2,
|
|
||||||
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
full_text = 'd := circle{radius: 10}',
|
|
||||||
kind = ' ',
|
|
||||||
lnum = 10,
|
|
||||||
indent = ' ',
|
|
||||||
node_scope = {
|
|
||||||
['end'] = {
|
|
||||||
character = 1,
|
|
||||||
line = 11,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 21,
|
|
||||||
line = 4,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
node_text = 'd',
|
|
||||||
range = {
|
|
||||||
['end'] = {
|
|
||||||
character = 2,
|
|
||||||
line = 9,
|
|
||||||
},
|
|
||||||
start = {
|
|
||||||
character = 1,
|
|
||||||
line = 9,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
text = ' d \t d := circle{radius: 10}',
|
|
||||||
type = 'var',
|
|
||||||
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
print(golden_result[1].node_text)
|
|
||||||
|
|
||||||
local busted = require('plenary/busted')
|
|
||||||
|
|
||||||
local eq = assert.are.same
|
|
||||||
local cur_dir = vim.fn.expand('%:p:h')
|
|
||||||
-- local status = require("plenary.reload").reload_module("go.nvim")
|
|
||||||
-- status = require("plenary.reload").reload_module("nvim-treesitter")
|
|
||||||
|
|
||||||
-- local ulog = require('go.utils').log
|
|
||||||
describe('should run lsp reference', function()
|
|
||||||
-- vim.fn.readfile('minimal.vim')
|
|
||||||
it('should show ts nodes', function()
|
|
||||||
local status = require('plenary.reload').reload_module('navigator')
|
|
||||||
local status = require('plenary.reload').reload_module('guihua')
|
|
||||||
local status = require('plenary.reload').reload_module('lspconfig')
|
|
||||||
|
|
||||||
vim.cmd([[packadd nvim-lspconfig]])
|
|
||||||
vim.cmd([[packadd navigator.lua]])
|
|
||||||
vim.cmd([[packadd guihua.lua]])
|
|
||||||
local path = cur_dir .. '/tests/fixtures/interface_test.go' -- %:p:h ? %:p
|
|
||||||
local cmd = " silent exe 'e " .. path .. "'"
|
|
||||||
vim.cmd(cmd)
|
|
||||||
vim.cmd([[cd %:p:h]])
|
|
||||||
local bufn = vim.fn.bufnr('')
|
|
||||||
-- require'lspconfig'.gopls.setup {}
|
|
||||||
require('navigator').setup({
|
|
||||||
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
|
|
||||||
})
|
|
||||||
|
|
||||||
-- allow gopls start
|
|
||||||
for i = 1, 10 do
|
|
||||||
vim.wait(400, function() end)
|
|
||||||
local clients = vim.lsp.get_active_clients()
|
|
||||||
print('lsp clients: ', #clients)
|
|
||||||
if #clients > 0 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.fn.setpos('.', { bufn, 15, 4, 0 }) -- width
|
|
||||||
|
|
||||||
vim.bo.filetype = 'go'
|
|
||||||
local view, items, w = require('navigator.treesitter').buf_ts()
|
|
||||||
eq(items[1].node_text, golden_result[1].node_text)
|
|
||||||
eq(items[2].node_text, golden_result[2].node_text)
|
|
||||||
end)
|
|
||||||
end)
|
|
@ -1,20 +0,0 @@
|
|||||||
local func = function(p, uv)
|
|
||||||
local before = os.time()
|
|
||||||
local async
|
|
||||||
async = uv.new_async(function(a, b, c)
|
|
||||||
p('in async notify callback')
|
|
||||||
p(a, b, c)
|
|
||||||
uv.close(async)
|
|
||||||
end)
|
|
||||||
local args = {500, 'string', nil, false, 5, "helloworld", async}
|
|
||||||
local unpack = unpack or table.unpack
|
|
||||||
uv.new_thread(function(num, s, null, bool, five, hw, asy)
|
|
||||||
local uv2 = require 'luv'
|
|
||||||
uv2.async_send(asy, 'a', true, 250)
|
|
||||||
uv2.sleep(1000)
|
|
||||||
end, unpack(args)):join()
|
|
||||||
local elapsed = (os.time() - before) * 1000
|
|
||||||
assert(elapsed >= 1000, "elapsed should be at least delay ")
|
|
||||||
end
|
|
||||||
|
|
||||||
func(print, vim.loop)
|
|
@ -1,58 +0,0 @@
|
|||||||
[selene]
|
|
||||||
base = "lua52"
|
|
||||||
name = "vim"
|
|
||||||
|
|
||||||
[vim]
|
|
||||||
any = true
|
|
||||||
|
|
||||||
[_G]
|
|
||||||
property = true
|
|
||||||
writable = "new-fields"
|
|
||||||
|
|
||||||
[_NgConfigValues]
|
|
||||||
any = true
|
|
||||||
# property = true
|
|
||||||
# writable = "full-write"
|
|
||||||
|
|
||||||
[debug]
|
|
||||||
property = true
|
|
||||||
|
|
||||||
[[describe.args]]
|
|
||||||
type = "string"
|
|
||||||
[[describe.args]]
|
|
||||||
type = "function"
|
|
||||||
|
|
||||||
[[it.args]]
|
|
||||||
type = "string"
|
|
||||||
[[it.args]]
|
|
||||||
type = "function"
|
|
||||||
|
|
||||||
[[before_each.args]]
|
|
||||||
type = "function"
|
|
||||||
[[after_each.args]]
|
|
||||||
type = "function"
|
|
||||||
|
|
||||||
[assert.is_not]
|
|
||||||
any = true
|
|
||||||
|
|
||||||
[[assert.equals.args]]
|
|
||||||
type = "any"
|
|
||||||
[[assert.equals.args]]
|
|
||||||
type = "any"
|
|
||||||
[[assert.equals.args]]
|
|
||||||
type = "any"
|
|
||||||
required = false
|
|
||||||
|
|
||||||
[[assert.same.args]]
|
|
||||||
type = "any"
|
|
||||||
[[assert.same.args]]
|
|
||||||
type = "any"
|
|
||||||
|
|
||||||
[[assert.truthy.args]]
|
|
||||||
type = "any"
|
|
||||||
|
|
||||||
[[assert.spy.args]]
|
|
||||||
type = "any"
|
|
||||||
|
|
||||||
[[assert.stub.args]]
|
|
||||||
type = "any"
|
|
@ -1,47 +0,0 @@
|
|||||||
---
|
|
||||||
base: lua52
|
|
||||||
name: vim
|
|
||||||
globals:
|
|
||||||
_G:
|
|
||||||
property: new-fields
|
|
||||||
_NgConfigValues:
|
|
||||||
any: true
|
|
||||||
after_each:
|
|
||||||
args:
|
|
||||||
- type: function
|
|
||||||
assert.equals:
|
|
||||||
args:
|
|
||||||
- type: any
|
|
||||||
- type: any
|
|
||||||
- required: false
|
|
||||||
type: any
|
|
||||||
assert.is_not:
|
|
||||||
any: true
|
|
||||||
assert.same:
|
|
||||||
args:
|
|
||||||
- type: any
|
|
||||||
- type: any
|
|
||||||
assert.spy:
|
|
||||||
args:
|
|
||||||
- type: any
|
|
||||||
assert.stub:
|
|
||||||
args:
|
|
||||||
- type: any
|
|
||||||
assert.truthy:
|
|
||||||
args:
|
|
||||||
- type: any
|
|
||||||
before_each:
|
|
||||||
args:
|
|
||||||
- type: function
|
|
||||||
debug:
|
|
||||||
property: read-only
|
|
||||||
describe:
|
|
||||||
args:
|
|
||||||
- type: string
|
|
||||||
- type: function
|
|
||||||
it:
|
|
||||||
args:
|
|
||||||
- type: string
|
|
||||||
- type: function
|
|
||||||
vim:
|
|
||||||
any: true
|
|
Loading…
Reference in New Issue