|
|
@ -1,9 +1,9 @@
|
|
|
|
-- todo allow config passed in
|
|
|
|
-- todo allow config passed in
|
|
|
|
local log = require"navigator.util".log
|
|
|
|
local log = require('navigator.util').log
|
|
|
|
local trace = require"navigator.util".trace
|
|
|
|
local trace = require('navigator.util').trace
|
|
|
|
local uv = vim.loop
|
|
|
|
local uv = vim.loop
|
|
|
|
|
|
|
|
|
|
|
|
local warn = require'navigator.util'.warn
|
|
|
|
local warn = require('navigator.util').warn
|
|
|
|
_NG_Loaded = {}
|
|
|
|
_NG_Loaded = {}
|
|
|
|
|
|
|
|
|
|
|
|
_LoadedFiletypes = {}
|
|
|
|
_LoadedFiletypes = {}
|
|
|
@ -12,22 +12,22 @@ packer_plugins = packer_plugins or nil -- suppress warnings
|
|
|
|
|
|
|
|
|
|
|
|
-- packer only
|
|
|
|
-- packer only
|
|
|
|
|
|
|
|
|
|
|
|
local highlight = require "navigator.lspclient.highlight"
|
|
|
|
local highlight = require('navigator.lspclient.highlight')
|
|
|
|
|
|
|
|
|
|
|
|
local has_lsp, lspconfig = pcall(require, "lspconfig")
|
|
|
|
local has_lsp, lspconfig = pcall(require, 'lspconfig')
|
|
|
|
if not has_lsp then
|
|
|
|
if not has_lsp then
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
setup = function()
|
|
|
|
setup = function()
|
|
|
|
print("loading lsp config failed LSP may not working correctly")
|
|
|
|
print('loading lsp config failed LSP may not working correctly')
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local util = lspconfig.util
|
|
|
|
local util = lspconfig.util
|
|
|
|
local config = require"navigator".config_values()
|
|
|
|
local config = require('navigator').config_values()
|
|
|
|
|
|
|
|
|
|
|
|
-- local cap = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
-- local cap = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
local on_attach = require("navigator.lspclient.attach").on_attach
|
|
|
|
local on_attach = require('navigator.lspclient.attach').on_attach
|
|
|
|
-- gopls["ui.completion.usePlaceholders"] = true
|
|
|
|
-- gopls["ui.completion.usePlaceholders"] = true
|
|
|
|
|
|
|
|
|
|
|
|
-- lua setup
|
|
|
|
-- lua setup
|
|
|
@ -37,25 +37,25 @@ local luadevcfg = {
|
|
|
|
library = {
|
|
|
|
library = {
|
|
|
|
vimruntime = true, -- runtime path
|
|
|
|
vimruntime = true, -- runtime path
|
|
|
|
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
|
|
|
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
|
|
|
plugins = {"nvim-treesitter", "plenary.nvim"}
|
|
|
|
plugins = { 'nvim-treesitter', 'plenary.nvim' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
lspconfig = {
|
|
|
|
lspconfig = {
|
|
|
|
-- cmd = {sumneko_binary},
|
|
|
|
-- cmd = {sumneko_binary},
|
|
|
|
on_attach = on_attach
|
|
|
|
on_attach = on_attach,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local luadev = {}
|
|
|
|
local luadev = {}
|
|
|
|
require'navigator.lazyloader'.load('lua-dev.nvim', 'folke/lua-dev.nvim')
|
|
|
|
require('navigator.lazyloader').load('lua-dev.nvim', 'folke/lua-dev.nvim')
|
|
|
|
local ok, l = pcall(require, "lua-dev")
|
|
|
|
local ok, l = pcall(require, 'lua-dev')
|
|
|
|
if ok and l then
|
|
|
|
if ok and l then
|
|
|
|
luadev = l.setup(luadevcfg)
|
|
|
|
luadev = l.setup(luadevcfg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local path = vim.split(package.path, ";")
|
|
|
|
local path = vim.split(package.path, ';')
|
|
|
|
|
|
|
|
|
|
|
|
table.insert(path, "lua/?.lua")
|
|
|
|
table.insert(path, 'lua/?.lua')
|
|
|
|
table.insert(path, "lua/?/init.lua")
|
|
|
|
table.insert(path, 'lua/?/init.lua')
|
|
|
|
|
|
|
|
|
|
|
|
local function add(lib)
|
|
|
|
local function add(lib)
|
|
|
|
for _, p in pairs(vim.fn.expand(lib, false, true)) do
|
|
|
|
for _, p in pairs(vim.fn.expand(lib, false, true)) do
|
|
|
@ -67,7 +67,7 @@ local function add(lib)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- add runtime
|
|
|
|
-- add runtime
|
|
|
|
add("$VIMRUNTIME")
|
|
|
|
add('$VIMRUNTIME')
|
|
|
|
|
|
|
|
|
|
|
|
-- add your config
|
|
|
|
-- add your config
|
|
|
|
-- local home = vim.fn.expand("$HOME")
|
|
|
|
-- local home = vim.fn.expand("$HOME")
|
|
|
@ -79,22 +79,22 @@ add(vim.fn.stdpath('config'))
|
|
|
|
-- add(home .. "/.local/share/nvim/site/pack/packer/start/*")
|
|
|
|
-- add(home .. "/.local/share/nvim/site/pack/packer/start/*")
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
|
|
library[vim.fn.expand("$VIMRUNTIME/lua")] = true
|
|
|
|
library[vim.fn.expand('$VIMRUNTIME/lua')] = true
|
|
|
|
library[vim.fn.expand("$VIMRUNTIME/lua/vim")] = true
|
|
|
|
library[vim.fn.expand('$VIMRUNTIME/lua/vim')] = true
|
|
|
|
library[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true
|
|
|
|
library[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
|
|
|
|
-- [vim.fn.expand("~/repos/nvim/lua")] = true
|
|
|
|
-- [vim.fn.expand("~/repos/nvim/lua")] = true
|
|
|
|
|
|
|
|
|
|
|
|
-- TODO remove onece PR #944 merged to lspconfig
|
|
|
|
-- TODO remove onece PR #944 merged to lspconfig
|
|
|
|
local path_sep = require"navigator.util".path_sep()
|
|
|
|
local path_sep = require('navigator.util').path_sep()
|
|
|
|
local strip_dir_pat = path_sep .. "([^" .. path_sep .. "]+)$"
|
|
|
|
local strip_dir_pat = path_sep .. '([^' .. path_sep .. ']+)$'
|
|
|
|
local strip_sep_pat = path_sep .. "$"
|
|
|
|
local strip_sep_pat = path_sep .. '$'
|
|
|
|
local dirname = function(pathname)
|
|
|
|
local dirname = function(pathname)
|
|
|
|
if not pathname or #pathname == 0 then
|
|
|
|
if not pathname or #pathname == 0 then
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local result = pathname:gsub(strip_sep_pat, ""):gsub(strip_dir_pat, "")
|
|
|
|
local result = pathname:gsub(strip_sep_pat, ''):gsub(strip_dir_pat, '')
|
|
|
|
if #result == 0 then
|
|
|
|
if #result == 0 then
|
|
|
|
return "/"
|
|
|
|
return '/'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -103,97 +103,101 @@ end
|
|
|
|
local setups = {
|
|
|
|
local setups = {
|
|
|
|
clojure_lsp = {
|
|
|
|
clojure_lsp = {
|
|
|
|
root_dir = function(fname)
|
|
|
|
root_dir = function(fname)
|
|
|
|
return util.root_pattern("deps.edn", "build.boot", "project.clj", "shadow-cljs.edn", "bb.edn", ".git")(fname)
|
|
|
|
return util.root_pattern('deps.edn', 'build.boot', 'project.clj', 'shadow-cljs.edn', 'bb.edn', '.git')(fname)
|
|
|
|
or util.path.dirname(fname)
|
|
|
|
or util.path.dirname(fname)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
filetypes = {"clojure", "edn"},
|
|
|
|
filetypes = { 'clojure', 'edn' },
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
cmd = {"clojure-lsp"}
|
|
|
|
cmd = { 'clojure-lsp' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
gopls = {
|
|
|
|
gopls = {
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
-- capabilities = cap,
|
|
|
|
-- capabilities = cap,
|
|
|
|
filetypes = {"go", "gomod"},
|
|
|
|
filetypes = { 'go', 'gomod' },
|
|
|
|
message_level = vim.lsp.protocol.MessageType.Error,
|
|
|
|
message_level = vim.lsp.protocol.MessageType.Error,
|
|
|
|
cmd = {
|
|
|
|
cmd = {
|
|
|
|
"gopls", -- share the gopls instance if there is one already
|
|
|
|
'gopls', -- share the gopls instance if there is one already
|
|
|
|
"-remote=auto", --[[ debug options ]] --
|
|
|
|
'-remote=auto', --[[ debug options ]] --
|
|
|
|
-- "-logfile=auto",
|
|
|
|
-- "-logfile=auto",
|
|
|
|
-- "-debug=:0",
|
|
|
|
-- "-debug=:0",
|
|
|
|
"-remote.debug=:0"
|
|
|
|
'-remote.debug=:0',
|
|
|
|
-- "-rpc.trace",
|
|
|
|
-- "-rpc.trace",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 1000},
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 1000 },
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
gopls = {
|
|
|
|
gopls = {
|
|
|
|
-- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
|
|
|
|
-- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
|
|
|
|
-- flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
-- flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
-- not supported
|
|
|
|
-- not supported
|
|
|
|
analyses = {unusedparams = true, unreachable = false},
|
|
|
|
analyses = { unusedparams = true, unreachable = false },
|
|
|
|
codelenses = {
|
|
|
|
codelenses = {
|
|
|
|
generate = true, -- show the `go generate` lens.
|
|
|
|
generate = true, -- show the `go generate` lens.
|
|
|
|
gc_details = true, -- // Show a code lens toggling the display of gc's choices.
|
|
|
|
gc_details = true, -- // Show a code lens toggling the display of gc's choices.
|
|
|
|
test = true,
|
|
|
|
test = true,
|
|
|
|
tidy = true
|
|
|
|
tidy = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
usePlaceholders = true,
|
|
|
|
usePlaceholders = true,
|
|
|
|
completeUnimported = true,
|
|
|
|
completeUnimported = true,
|
|
|
|
staticcheck = true,
|
|
|
|
staticcheck = true,
|
|
|
|
matcher = "fuzzy",
|
|
|
|
matcher = 'fuzzy',
|
|
|
|
diagnosticsDelay = "500ms",
|
|
|
|
diagnosticsDelay = '500ms',
|
|
|
|
experimentalWatchedFileDelay = "1000ms",
|
|
|
|
experimentalWatchedFileDelay = '1000ms',
|
|
|
|
symbolMatcher = "fuzzy",
|
|
|
|
symbolMatcher = 'fuzzy',
|
|
|
|
gofumpt = false, -- true, -- turn on for new repos, gofmpt is good but also create code turmoils
|
|
|
|
gofumpt = false, -- true, -- turn on for new repos, gofmpt is good but also create code turmoils
|
|
|
|
buildFlags = {"-tags", "integration"}
|
|
|
|
buildFlags = { '-tags', 'integration' },
|
|
|
|
-- buildFlags = {"-tags", "functional"}
|
|
|
|
-- buildFlags = {"-tags", "functional"}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
root_dir = function(fname)
|
|
|
|
root_dir = function(fname)
|
|
|
|
return util.root_pattern("go.mod", ".git")(fname) or dirname(fname) -- util.path.dirname(fname)
|
|
|
|
return util.root_pattern('go.mod', '.git')(fname) or dirname(fname) -- util.path.dirname(fname)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
clangd = {
|
|
|
|
clangd = {
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
|
|
cmd = {
|
|
|
|
cmd = {
|
|
|
|
"clangd", "--background-index", "--suggest-missing-includes", "--clang-tidy",
|
|
|
|
'clangd',
|
|
|
|
"--header-insertion=iwyu", "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*",
|
|
|
|
'--background-index',
|
|
|
|
"--cross-file-rename"
|
|
|
|
'--suggest-missing-includes',
|
|
|
|
|
|
|
|
'--clang-tidy',
|
|
|
|
|
|
|
|
'--header-insertion=iwyu',
|
|
|
|
|
|
|
|
'--clang-tidy-checks=-*,llvm-*,clang-analyzer-*',
|
|
|
|
|
|
|
|
'--cross-file-rename',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filetypes = {"c", "cpp", "objc", "objcpp"},
|
|
|
|
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
|
|
|
on_attach = function(client)
|
|
|
|
on_attach = function(client)
|
|
|
|
client.resolved_capabilities.document_formatting = true
|
|
|
|
client.resolved_capabilities.document_formatting = true
|
|
|
|
on_attach(client)
|
|
|
|
on_attach(client)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
rust_analyzer = {
|
|
|
|
rust_analyzer = {
|
|
|
|
root_dir = function(fname)
|
|
|
|
root_dir = function(fname)
|
|
|
|
return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname) or util.path.dirname(fname)
|
|
|
|
return util.root_pattern('Cargo.toml', 'rust-project.json', '.git')(fname) or util.path.dirname(fname)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
filetypes = {"rust"},
|
|
|
|
filetypes = { 'rust' },
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
["rust-analyzer"] = {
|
|
|
|
['rust-analyzer'] = {
|
|
|
|
assist = {importMergeBehavior = "last", importPrefix = "by_self"},
|
|
|
|
assist = { importMergeBehavior = 'last', importPrefix = 'by_self' },
|
|
|
|
cargo = {loadOutDirsFromCheck = true},
|
|
|
|
cargo = { loadOutDirsFromCheck = true },
|
|
|
|
procMacro = {enable = true}
|
|
|
|
procMacro = { enable = true },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 500}
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sqls = {
|
|
|
|
sqls = {
|
|
|
|
filetypes = {"sql"},
|
|
|
|
filetypes = { 'sql' },
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
client.resolved_capabilities.execute_command = true
|
|
|
|
client.resolved_capabilities.execute_command = true
|
|
|
|
highlight.diagnositc_config_sign()
|
|
|
|
highlight.diagnositc_config_sign()
|
|
|
|
require"sqls".setup {picker = "telescope"} -- or default
|
|
|
|
require('sqls').setup({ picker = 'telescope' }) -- or default
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
cmd = {"sqls", "-config", "$HOME/.config/sqls/config.yml"}
|
|
|
|
cmd = { 'sqls', '-config', '$HOME/.config/sqls/config.yml' },
|
|
|
|
-- alterantively:
|
|
|
|
-- alterantively:
|
|
|
|
-- connections = {
|
|
|
|
-- connections = {
|
|
|
|
-- {
|
|
|
|
-- {
|
|
|
@ -201,92 +205,124 @@ local setups = {
|
|
|
|
-- datasourcename = 'host=127.0.0.1 port=5432 user=postgres password=password dbname=user_db sslmode=disable',
|
|
|
|
-- datasourcename = 'host=127.0.0.1 port=5432 user=postgres password=password dbname=user_db sslmode=disable',
|
|
|
|
-- },
|
|
|
|
-- },
|
|
|
|
-- },
|
|
|
|
-- },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sumneko_lua = {
|
|
|
|
sumneko_lua = {
|
|
|
|
cmd = {"lua-language-server"},
|
|
|
|
cmd = { 'lua-language-server' },
|
|
|
|
filetypes = {"lua"},
|
|
|
|
filetypes = { 'lua' },
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
runtime = {
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
|
|
version = "LuaJIT",
|
|
|
|
version = 'LuaJIT',
|
|
|
|
-- Setup your lua path
|
|
|
|
-- Setup your lua path
|
|
|
|
path = vim.split(package.path, ";")
|
|
|
|
path = vim.split(package.path, ';'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
diagnostics = {
|
|
|
|
enable = true,
|
|
|
|
enable = true,
|
|
|
|
-- Get the language server to recognize the `vim` global
|
|
|
|
-- Get the language server to recognize the `vim` global
|
|
|
|
globals = {"vim", "describe", "it", "before_each", "after_each", "teardown", "pending"}
|
|
|
|
globals = { 'vim', 'describe', 'it', 'before_each', 'after_each', 'teardown', 'pending' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
completion = {callSnippet = "Both"},
|
|
|
|
completion = { callSnippet = 'Both' },
|
|
|
|
workspace = {
|
|
|
|
workspace = {
|
|
|
|
-- Make the server aware of Neovim runtime files
|
|
|
|
-- Make the server aware of Neovim runtime files
|
|
|
|
library = library,
|
|
|
|
library = library,
|
|
|
|
maxPreload = 2000,
|
|
|
|
maxPreload = 2000,
|
|
|
|
preloadFileSize = 40000
|
|
|
|
preloadFileSize = 40000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
telemetry = {enable = false}
|
|
|
|
telemetry = { enable = false },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
on_new_config = function(cfg, root)
|
|
|
|
on_new_config = function(cfg, root)
|
|
|
|
local libs = vim.tbl_deep_extend('force', {}, library)
|
|
|
|
local libs = vim.tbl_deep_extend('force', {}, library)
|
|
|
|
libs[root] = nil
|
|
|
|
libs[root] = nil
|
|
|
|
cfg.settings.Lua.workspace.library = libs
|
|
|
|
cfg.settings.Lua.workspace.library = libs
|
|
|
|
return cfg
|
|
|
|
return cfg
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
pyright = {
|
|
|
|
pyright = {
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
cmd = {"pyright-langserver", "--stdio"},
|
|
|
|
cmd = { 'pyright-langserver', '--stdio' },
|
|
|
|
filetypes = {"python"},
|
|
|
|
filetypes = { 'python' },
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
python = {
|
|
|
|
python = {
|
|
|
|
formatting = {provider = 'black'},
|
|
|
|
formatting = { provider = 'black' },
|
|
|
|
analysis = {
|
|
|
|
analysis = {
|
|
|
|
autoSearchPaths = true,
|
|
|
|
autoSearchPaths = true,
|
|
|
|
useLibraryCodeForTypes = true,
|
|
|
|
useLibraryCodeForTypes = true,
|
|
|
|
diagnosticMode = "workspace"
|
|
|
|
diagnosticMode = 'workspace',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ccls = {
|
|
|
|
ccls = {
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
init_options = {
|
|
|
|
init_options = {
|
|
|
|
compilationDatabaseDirectory = "build",
|
|
|
|
compilationDatabaseDirectory = 'build',
|
|
|
|
root_dir = [[ util.root_pattern("compile_commands.json", "compile_flags.txt", "CMakeLists.txt", "Makefile", ".git") or util.path.dirname ]],
|
|
|
|
root_dir = [[ util.root_pattern("compile_commands.json", "compile_flags.txt", "CMakeLists.txt", "Makefile", ".git") or util.path.dirname ]],
|
|
|
|
index = {threads = 2},
|
|
|
|
index = { threads = 2 },
|
|
|
|
clang = {excludeArgs = {"-frounding-math"}}
|
|
|
|
clang = { excludeArgs = { '-frounding-math' } },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flags = {allow_incremental_sync = true}
|
|
|
|
flags = { allow_incremental_sync = true },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
jdtls = {
|
|
|
|
jdtls = {
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
java = {signatureHelp = {enabled = true}, contentProvider = {preferred = 'fernflower'}}
|
|
|
|
java = { signatureHelp = { enabled = true }, contentProvider = { preferred = 'fernflower' } },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setups.sumneko_lua = vim.tbl_deep_extend('force', luadev, setups.sumneko_lua)
|
|
|
|
setups.sumneko_lua = vim.tbl_deep_extend('force', luadev, setups.sumneko_lua)
|
|
|
|
|
|
|
|
|
|
|
|
local servers = {
|
|
|
|
local servers = {
|
|
|
|
"angularls", "gopls", "tsserver", "flow", "bashls", "dockerls", "julials", "pylsp", "pyright",
|
|
|
|
'angularls',
|
|
|
|
"jedi_language_server", "jdtls", "sumneko_lua", "vimls", "html", "jsonls", "solargraph", "cssls",
|
|
|
|
'gopls',
|
|
|
|
"yamlls", "clangd", "ccls", "sqls", "denols", "graphql", "dartls", "dotls",
|
|
|
|
'tsserver',
|
|
|
|
"kotlin_language_server", "nimls", "intelephense", "vuels", "phpactor", "omnisharp",
|
|
|
|
'flow',
|
|
|
|
"r_language_server", "rust_analyzer", "terraformls", "svelte", "texlab", "clojure_lsp"
|
|
|
|
'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',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local has_lspinst = false
|
|
|
|
local has_lspinst = false
|
|
|
|
|
|
|
|
|
|
|
|
if config.lsp_installer == true then
|
|
|
|
if config.lsp_installer == true then
|
|
|
|
has_lspinst, _ = pcall(require, "nvim-lsp-installer")
|
|
|
|
has_lspinst, _ = pcall(require, 'nvim-lsp-installer')
|
|
|
|
if has_lspinst then
|
|
|
|
if has_lspinst then
|
|
|
|
local srvs = require'nvim-lsp-installer.servers'.get_installed_servers()
|
|
|
|
local srvs = require('nvim-lsp-installer.servers').get_installed_servers()
|
|
|
|
log('lsp_installered servers', srvs)
|
|
|
|
log('lsp_installered servers', srvs)
|
|
|
|
if #srvs > 0 then
|
|
|
|
if #srvs > 0 then
|
|
|
|
servers = srvs
|
|
|
|
servers = srvs
|
|
|
@ -300,7 +336,7 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
local ng_default_cfg = {
|
|
|
|
local ng_default_cfg = {
|
|
|
|
on_attach = on_attach,
|
|
|
|
on_attach = on_attach,
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 1000}
|
|
|
|
flags = { allow_incremental_sync = true, debounce_text_changes = 1000 },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local configs = {}
|
|
|
|
local configs = {}
|
|
|
@ -315,7 +351,7 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
|
|
|
|
|
|
|
|
log(ft, client, loaded)
|
|
|
|
log(ft, client, loaded)
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
log("not supported by nvim", client)
|
|
|
|
log('not supported by nvim', client)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -342,26 +378,25 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
for _, c in pairs(loaded) do
|
|
|
|
for _, c in pairs(loaded) do
|
|
|
|
if client == c then
|
|
|
|
if client == c then
|
|
|
|
-- loaded
|
|
|
|
-- loaded
|
|
|
|
trace(client, "already been loaded for", ft, loaded)
|
|
|
|
trace(client, 'already been loaded for', ft, loaded)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
error("client " .. client .. " not supported")
|
|
|
|
error('client ' .. client .. ' not supported')
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
trace("load cfg", cfg)
|
|
|
|
trace('load cfg', cfg)
|
|
|
|
log('lspconfig setup')
|
|
|
|
log('lspconfig setup')
|
|
|
|
-- log(lspconfig.available_servers())
|
|
|
|
-- log(lspconfig.available_servers())
|
|
|
|
-- force reload with config
|
|
|
|
-- force reload with config
|
|
|
|
lspconfig[client].setup(cfg)
|
|
|
|
lspconfig[client].setup(cfg)
|
|
|
|
vim.defer_fn(function()
|
|
|
|
vim.defer_fn(function()
|
|
|
|
|
|
|
|
|
|
|
|
vim.cmd([[doautocmd FileType ]] .. ft)
|
|
|
|
vim.cmd([[doautocmd FileType ]] .. ft)
|
|
|
|
end, 100)
|
|
|
|
end, 100)
|
|
|
|
log(client, "loading for", ft)
|
|
|
|
log(client, 'loading for', ft)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- need to verify the lsp server is up
|
|
|
|
-- need to verify the lsp server is up
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -378,9 +413,9 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.tagSupport = {valueSet = {1}}
|
|
|
|
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
|
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
|
|
properties = {'documentation', 'detail', 'additionalTextEdits'}
|
|
|
|
properties = { 'documentation', 'detail', 'additionalTextEdits' },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
capabilities.workspace.configuration = true
|
|
|
|
capabilities.workspace.configuration = true
|
|
|
|
|
|
|
|
|
|
|
@ -396,13 +431,13 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
if lspclient.name then
|
|
|
|
if lspclient.name then
|
|
|
|
lspclient = lspclient.name
|
|
|
|
lspclient = lspclient.name
|
|
|
|
else
|
|
|
|
else
|
|
|
|
warn("incorrect set for lspclient", vim.inspect(lspclient))
|
|
|
|
warn('incorrect set for lspclient', vim.inspect(lspclient))
|
|
|
|
goto continue
|
|
|
|
goto continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if user_lsp_opts[lspclient] ~= nil and user_lsp_opts[lspclient].filetypes ~= nil then
|
|
|
|
if user_lsp_opts[lspclient] ~= nil and user_lsp_opts[lspclient].filetypes ~= nil then
|
|
|
|
if not vim.tbl_contains(user_lsp_opts[lspclient].filetypes, ft) then
|
|
|
|
if not vim.tbl_contains(user_lsp_opts[lspclient].filetypes, ft) then
|
|
|
|
trace("ft", ft, "disabled for", lspclient)
|
|
|
|
trace('ft', ft, 'disabled for', lspclient)
|
|
|
|
goto continue
|
|
|
|
goto continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -412,30 +447,30 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if vim.tbl_contains(config.lsp.disable_lsp or {}, lspclient) then
|
|
|
|
if vim.tbl_contains(config.lsp.disable_lsp or {}, lspclient) then
|
|
|
|
log("disable lsp", lspclient)
|
|
|
|
log('disable lsp', lspclient)
|
|
|
|
goto continue
|
|
|
|
goto continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local default_config = {}
|
|
|
|
local default_config = {}
|
|
|
|
log(lspclient)
|
|
|
|
log(lspclient)
|
|
|
|
if lspconfig[lspclient] == nil then
|
|
|
|
if lspconfig[lspclient] == nil then
|
|
|
|
print("lspclient", lspclient, "no longer support by lspconfig, please submit an issue")
|
|
|
|
print('lspclient', lspclient, 'no longer support by lspconfig, please submit an issue')
|
|
|
|
goto continue
|
|
|
|
goto continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if lspconfig[lspclient].document_config and lspconfig[lspclient].document_config.default_config then
|
|
|
|
if lspconfig[lspclient].document_config and lspconfig[lspclient].document_config.default_config then
|
|
|
|
default_config = lspconfig[lspclient].document_config.default_config
|
|
|
|
default_config = lspconfig[lspclient].document_config.default_config
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print("missing document config for client: ", lspclient)
|
|
|
|
print('missing document config for client: ', lspclient)
|
|
|
|
goto continue
|
|
|
|
goto continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
default_config = vim.tbl_deep_extend("force", default_config, ng_default_cfg)
|
|
|
|
default_config = vim.tbl_deep_extend('force', default_config, ng_default_cfg)
|
|
|
|
local cfg = setups[lspclient] or {}
|
|
|
|
local cfg = setups[lspclient] or {}
|
|
|
|
cfg = vim.tbl_deep_extend("keep", cfg, default_config)
|
|
|
|
cfg = vim.tbl_deep_extend('keep', cfg, default_config)
|
|
|
|
-- filetype disabled
|
|
|
|
-- filetype disabled
|
|
|
|
if not vim.tbl_contains(cfg.filetypes or {}, ft) then
|
|
|
|
if not vim.tbl_contains(cfg.filetypes or {}, ft) then
|
|
|
|
trace("ft", ft, "disabled for", lspclient)
|
|
|
|
trace('ft', ft, 'disabled for', lspclient)
|
|
|
|
goto continue
|
|
|
|
goto continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -447,10 +482,10 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
|
|
|
|
|
|
|
log(lspclient, config.lsp.disable_format_cap)
|
|
|
|
log(lspclient, config.lsp.disable_format_cap)
|
|
|
|
if vim.tbl_contains(config.lsp.disable_format_cap or {}, lspclient) then
|
|
|
|
if vim.tbl_contains(config.lsp.disable_format_cap or {}, lspclient) then
|
|
|
|
log("fileformat disabled for ", lspclient)
|
|
|
|
log('fileformat disabled for ', lspclient)
|
|
|
|
disable_fmt = true
|
|
|
|
disable_fmt = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
cfg = vim.tbl_deep_extend("force", cfg, user_lsp_opts[lspclient])
|
|
|
|
cfg = vim.tbl_deep_extend('force', cfg, user_lsp_opts[lspclient])
|
|
|
|
if config.combined_attach == nil then
|
|
|
|
if config.combined_attach == nil then
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
on_attach(client, bufnr)
|
|
|
@ -459,9 +494,9 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if config.combined_attach == "mine" then
|
|
|
|
if config.combined_attach == 'mine' then
|
|
|
|
if config.on_attach == nil then
|
|
|
|
if config.on_attach == nil then
|
|
|
|
error("on attach not provided")
|
|
|
|
error('on attach not provided')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
@ -470,7 +505,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if config.combined_attach == "both" then
|
|
|
|
if config.combined_attach == 'both' then
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
if config.on_attach then
|
|
|
|
if config.on_attach then
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
@ -487,7 +522,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
cfg.on_init = function(client)
|
|
|
|
cfg.on_init = function(client)
|
|
|
|
if client and client.config and client.config.settings then
|
|
|
|
if client and client.config and client.config.settings then
|
|
|
|
client.notify('workspace/didChangeConfiguration', {settings = client.config.settings})
|
|
|
|
client.notify('workspace/didChangeConfiguration', { settings = client.config.settings })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -495,7 +530,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
log('loading', lspclient, 'name', lspconfig[lspclient].name, 'has lspinst', has_lspinst)
|
|
|
|
log('loading', lspclient, 'name', lspconfig[lspclient].name, 'has lspinst', has_lspinst)
|
|
|
|
-- start up lsp
|
|
|
|
-- start up lsp
|
|
|
|
if has_lspinst and _NgConfigValues.lsp_installer then
|
|
|
|
if has_lspinst and _NgConfigValues.lsp_installer then
|
|
|
|
local installed, installer_cfg = require("nvim-lsp-installer.servers").get_server(lspconfig[lspclient].name)
|
|
|
|
local installed, installer_cfg = require('nvim-lsp-installer.servers').get_server(lspconfig[lspclient].name)
|
|
|
|
|
|
|
|
|
|
|
|
log('lsp server', installer_cfg, lspconfig[lspclient].name)
|
|
|
|
log('lsp server', installer_cfg, lspconfig[lspclient].name)
|
|
|
|
if installed and installer_cfg then
|
|
|
|
if installed and installer_cfg then
|
|
|
@ -511,12 +546,30 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
::continue::
|
|
|
|
::continue::
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not _NG_Loaded['null_ls'] then
|
|
|
|
|
|
|
|
local nulls_cfg = user_lsp_opts['null_ls']
|
|
|
|
|
|
|
|
if nulls_cfg then
|
|
|
|
|
|
|
|
local cfg = {}
|
|
|
|
|
|
|
|
cfg = vim.tbl_deep_extend('keep', cfg, nulls_cfg)
|
|
|
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
|
|
|
if efm_cfg.on_attach then
|
|
|
|
|
|
|
|
efm_cfg.on_attach(client, bufnr)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lspconfig['null-ls'].setup(cfg)
|
|
|
|
|
|
|
|
log('null-ls loading')
|
|
|
|
|
|
|
|
_NG_Loaded['null-ls'] = true
|
|
|
|
|
|
|
|
configs['null-ls'] = cfg
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if not _NG_Loaded['efm'] then
|
|
|
|
if not _NG_Loaded['efm'] then
|
|
|
|
local efm_cfg = user_lsp_opts['efm']
|
|
|
|
local efm_cfg = user_lsp_opts['efm']
|
|
|
|
if efm_cfg then
|
|
|
|
if efm_cfg then
|
|
|
|
|
|
|
|
|
|
|
|
local cfg = {}
|
|
|
|
local cfg = {}
|
|
|
|
cfg = vim.tbl_deep_extend("keep", cfg, efm_cfg)
|
|
|
|
cfg = vim.tbl_deep_extend('keep', cfg, efm_cfg)
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
if efm_cfg.on_attach then
|
|
|
|
if efm_cfg.on_attach then
|
|
|
|
efm_cfg.on_attach(client, bufnr)
|
|
|
|
efm_cfg.on_attach(client, bufnr)
|
|
|
@ -548,58 +601,67 @@ local function get_cfg(client)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function setup(user_opts)
|
|
|
|
local function setup(user_opts)
|
|
|
|
log(user_opts)
|
|
|
|
|
|
|
|
local ft = vim.bo.filetype
|
|
|
|
local ft = vim.bo.filetype
|
|
|
|
local bufnr = tostring(vim.api.nvim_get_current_buf())
|
|
|
|
local bufnr = vim.api.nvim_get_current_buf()
|
|
|
|
if _LoadedFiletypes[ft .. bufnr] then
|
|
|
|
local uri = vim.uri_from_bufnr(bufnr)
|
|
|
|
log("navigator was loaded for ft", ft)
|
|
|
|
|
|
|
|
|
|
|
|
if uri == 'file://' or uri == 'file:///' then
|
|
|
|
|
|
|
|
log('skip loading for ft ', ft, uri)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
log(user_opts)
|
|
|
|
|
|
|
|
log(uri)
|
|
|
|
|
|
|
|
if _LoadedFiletypes[ft .. tostring(bufnr)] then
|
|
|
|
|
|
|
|
log('navigator was loaded for ft', ft)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local disable_ft = {
|
|
|
|
local disable_ft = {
|
|
|
|
"NvimTree", "guihua", "clap_input", "clap_spinner", "vista", "vista_kind", "TelescopePrompt",
|
|
|
|
'NvimTree',
|
|
|
|
"guihua_rust", "csv", "txt", "defx", "packer"
|
|
|
|
'guihua',
|
|
|
|
|
|
|
|
'clap_input',
|
|
|
|
|
|
|
|
'clap_spinner',
|
|
|
|
|
|
|
|
'vista',
|
|
|
|
|
|
|
|
'vista_kind',
|
|
|
|
|
|
|
|
'TelescopePrompt',
|
|
|
|
|
|
|
|
'guihua_rust',
|
|
|
|
|
|
|
|
'csv',
|
|
|
|
|
|
|
|
'txt',
|
|
|
|
|
|
|
|
'defx',
|
|
|
|
|
|
|
|
'packer',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for i = 1, #disable_ft do
|
|
|
|
for i = 1, #disable_ft do
|
|
|
|
if ft == disable_ft[i] or _LoadedFiletypes[ft] then
|
|
|
|
if ft == disable_ft[i] or _LoadedFiletypes[ft] then
|
|
|
|
trace("navigator disabled for ft or it is loaded", ft)
|
|
|
|
trace('navigator disabled for ft or it is loaded', ft)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if user_opts ~= nil then
|
|
|
|
if user_opts ~= nil then
|
|
|
|
log("navigator user setup", user_opts)
|
|
|
|
log('navigator user setup', user_opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
trace(debug.traceback())
|
|
|
|
trace(debug.traceback())
|
|
|
|
if #vim.lsp.buf_get_clients() > 0 and user_opts == nil then
|
|
|
|
if #vim.lsp.buf_get_clients() > 0 and user_opts == nil then
|
|
|
|
log("already setup")
|
|
|
|
log('already setup')
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
user_opts = user_opts or config -- incase setup was triggered from autocmd
|
|
|
|
user_opts = user_opts or config -- incase setup was triggered from autocmd
|
|
|
|
|
|
|
|
|
|
|
|
if ft == nil then
|
|
|
|
if ft == nil then
|
|
|
|
ft = vim.api.nvim_buf_get_option(0, "filetype")
|
|
|
|
ft = vim.api.nvim_buf_get_option(bufnr, 'filetype')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if ft == nil or ft == "" then
|
|
|
|
if ft == nil or ft == '' then
|
|
|
|
|
|
|
|
log('nil filetype, callback')
|
|
|
|
vim.defer_fn(function()
|
|
|
|
vim.defer_fn(function()
|
|
|
|
setup(user_opts)
|
|
|
|
setup(user_opts)
|
|
|
|
end, 500)
|
|
|
|
end, 200)
|
|
|
|
|
|
|
|
|
|
|
|
log("nil filetype, callback")
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local retry = true
|
|
|
|
local retry = true
|
|
|
|
|
|
|
|
|
|
|
|
local bufnr = vim.fn.bufnr()
|
|
|
|
|
|
|
|
local uri = vim.uri_from_bufnr(bufnr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if uri == 'file://' or uri == 'file:///' then
|
|
|
|
|
|
|
|
log("skip loading for ft ", ft, uri)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trace('setup', user_opts)
|
|
|
|
trace('setup', user_opts)
|
|
|
|
log("loading for ft ", ft, uri)
|
|
|
|
log('loading for ft ', ft, uri)
|
|
|
|
highlight.diagnositc_config_sign()
|
|
|
|
highlight.diagnositc_config_sign()
|
|
|
|
highlight.add_highlight()
|
|
|
|
highlight.add_highlight()
|
|
|
|
local lsp_opts = user_opts.lsp
|
|
|
|
local lsp_opts = user_opts.lsp
|
|
|
@ -609,10 +671,12 @@ local function setup(user_opts)
|
|
|
|
if slua and not slua.cmd then
|
|
|
|
if slua and not slua.cmd then
|
|
|
|
if slua.sumneko_root_path and slua.sumneko_binary then
|
|
|
|
if slua.sumneko_root_path and slua.sumneko_binary then
|
|
|
|
lsp_opts.sumneko_lua.cmd = {
|
|
|
|
lsp_opts.sumneko_lua.cmd = {
|
|
|
|
slua.sumneko_binary, "-E", slua.sumneko_root_path .. "/main.lua"
|
|
|
|
slua.sumneko_binary,
|
|
|
|
|
|
|
|
'-E',
|
|
|
|
|
|
|
|
slua.sumneko_root_path .. '/main.lua',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
lsp_opts.sumneko_lua.cmd = {"lua-language-server"}
|
|
|
|
lsp_opts.sumneko_lua.cmd = { 'lua-language-server' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -621,18 +685,40 @@ local function setup(user_opts)
|
|
|
|
|
|
|
|
|
|
|
|
--- if code line enabled
|
|
|
|
--- if code line enabled
|
|
|
|
if _NgConfigValues.lsp.code_lens then
|
|
|
|
if _NgConfigValues.lsp.code_lens then
|
|
|
|
require("navigator.codelens").setup()
|
|
|
|
require('navigator.codelens').setup()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
_LoadedFiletypes[ft] = true
|
|
|
|
_LoadedFiletypes[ft] = true
|
|
|
|
-- _LoadedFiletypes[ft] = vim.tbl_extend("keep", _LoadedFiletypes[ft] or {}, {ft})
|
|
|
|
-- _LoadedFiletypes[ft] = vim.tbl_extend("keep", _LoadedFiletypes[ft] or {}, {ft})
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- append lsps to servers
|
|
|
|
-- append lsps to servers
|
|
|
|
function add_servers(lsps)
|
|
|
|
function add_servers(lsps)
|
|
|
|
vim.validate {lsps = {lsps, 't'}}
|
|
|
|
vim.validate({ lsps = { lsps, 't' } })
|
|
|
|
vim.list_extend(servers, lsps)
|
|
|
|
vim.list_extend(servers, lsps)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return {setup = setup, get_cfg = get_cfg, lsp = servers, add_servers = add_servers}
|
|
|
|
function on_filetype()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local bufnr = vim.api.nvim_get_current_buf()
|
|
|
|
|
|
|
|
local uri = vim.uri_from_bufnr(bufnr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local ft = vim.bo.filetype
|
|
|
|
|
|
|
|
if ft == nil then return end
|
|
|
|
|
|
|
|
if uri == 'file://' or uri == 'file:///' then
|
|
|
|
|
|
|
|
log('skip loading for ft ', ft, uri)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log(uri)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local wids = vim.fn.win_findbuf(bufnr)
|
|
|
|
|
|
|
|
if wins == nil or wins == {} then
|
|
|
|
|
|
|
|
log('buf not shown return')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
setup()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { setup = setup, get_cfg = get_cfg, lsp = servers, add_servers = add_servers , on_filetype = on_filetype}
|
|
|
|