update doc and configuration for float win size

pull/4/head
ray-x 3 years ago
parent 0c89f6d673
commit 54f4fca0c0

@ -70,6 +70,17 @@ EOF
Generally speaking, you could remove most part of your lspconfig.lua and use the hooks in navigator.lua Generally speaking, you could remove most part of your lspconfig.lua and use the hooks in navigator.lua
## Depency
- lspconfig
- guihua (provides floating window, FZY)
- Optional:
- lsp-status
- lsp-signature
- vim-illuminate
The plugin can be loaded lazily (packer `opt = true` ), And it will check if optional plugins existance and load those plugins only if they existed.
## Usage ## Usage
Please refer to lua/navigator/lspclient/mapping.lua on key mappings. Should be able to work out-of-box. Please refer to lua/navigator/lspclient/mapping.lua on key mappings. Should be able to work out-of-box.
@ -138,11 +149,7 @@ Treetsitter symbols in all buffers
# Todo # Todo
- Early phase, bugs expected - Early phase, bugs expected, PR and suggestions are welcome
- Async (some of the requests is slow on large codebase and might be good to use co-rountine) - Async (some of the requests is slow on large codebases and might be good to use co-rountine)
- More clients. I use go, python, js/ts, java, c/cpp, lua most of the time. Do not test other languages (e.g dart, swift etc) - More clients. I use go, python, js/ts, java, c/cpp, lua most of the time. Do not test other languages (e.g dart, swift etc)
- Configure options - Configuration options
```
```

@ -1,8 +1,14 @@
local M = {} local M = {}
_NgConfigValues ={
M.config_values ={
debug = false, -- log output debug = false, -- log output
code_action_icon = '', code_action_icon = '',
width = nil, -- valeu of cols TODO allow float e.g. 0.6
height = nil,
on_attach = function(client, bufnr)
-- your on_attach will be called at end of navigator on_attach
end,
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",
code_action_prompt = { code_action_prompt = {
enable = true, enable = true,
sign = true, sign = true,
@ -11,6 +17,8 @@ M.config_values ={
}, },
} }
vim.cmd("command! -nargs=0 LspLog call v:lua.open_lsp_log()") vim.cmd("command! -nargs=0 LspLog call v:lua.open_lsp_log()")
vim.cmd("command! -nargs=0 LspRestart call v:lua.reload_lsp()") vim.cmd("command! -nargs=0 LspRestart call v:lua.reload_lsp()")
@ -18,20 +26,23 @@ local extend_config = function(opts)
opts = opts or {} opts = opts or {}
if next(opts) == nil then return end if next(opts) == nil then return end
for key,value in pairs(opts) do for key,value in pairs(opts) do
if M.config_values[key] == nil then if _NgConfigValues[key] == nil then
error(string.format('[] Key %s not valid',key)) error(string.format('[] Key %s not valid',key))
return return
end end
if type(M.config_values[key]) == 'table' then if type(M.config_values[key]) == 'table' then
for k,v in pairs(value) do for k,v in pairs(value) do
M.config_values[key][k] = v _NgConfigValues[key][k] = v
end end
else else
M.config_values[key] = value _NgConfigValues[key] = value
end end
end end
end end
M.config_values = function() return _NgConfigValues end
M.setup = function(cfg) M.setup = function(cfg)
extend_config(cfg) extend_config(cfg)
-- print("loading navigator") -- print("loading navigator")

@ -2,7 +2,7 @@ local util = require "navigator.util"
local log = util.log local log = util.log
local code_action = {} local code_action = {}
local gui = require "navigator.gui" local gui = require "navigator.gui"
local config = require("navigator").config_values local config = require("navigator").config_values()
local api = vim.api local api = vim.api
function code_action.code_action_handler(err, _, actions, cid, bufnr, _, customSelectionHandler) function code_action.code_action_handler(err, _, actions, cid, bufnr, _, customSelectionHandler)
log(cid, bufnr) log(cid, bufnr)

@ -86,6 +86,8 @@ function M.preview_uri(opts) -- uri, width, line, col, offset_x, offset_y
end end
function M.new_list_view(opts) function M.new_list_view(opts)
local config = require("navigator").config_values()
local items = opts.items local items = opts.items
local data = {} local data = {}
if opts.rawdata then if opts.rawdata then
@ -94,8 +96,8 @@ function M.new_list_view(opts)
data = require "guihua.util".aggregate_filename(items, opts) data = require "guihua.util".aggregate_filename(items, opts)
end end
local wwidth = api.nvim_get_option("columns") local wwidth = api.nvim_get_option("columns")
local width = opts.width or math.floor(wwidth * 0.8) local width = config.width or opts.width or math.floor(wwidth * 0.8)
local wheight = math.floor(api.nvim_get_option("lines") * 0.8) local wheight = config.height or math.floor(api.nvim_get_option("lines") * 0.8)
local prompt = opts.prompt or false local prompt = opts.prompt or false
if data and not vim.tbl_isempty(data) then if data and not vim.tbl_isempty(data) then
-- replace -- replace

@ -66,7 +66,7 @@ M.on_attach = function(client, bufnr)
require("navigator.lspclient.mapping").setup({client = client, bufnr = bufnr, cap = client.resolved_capabilities}) require("navigator.lspclient.mapping").setup({client = client, bufnr = bufnr, cap = client.resolved_capabilities})
vim.cmd [[packadd vim-illuminate]] vim.cmd [[packadd vim-illuminate]]
local hasilm, ilm = pcall(require, "illuminate") local hasilm, ilm = pcall(require, "illuminate") -- package.loaded["illuminate"]
if hasilm then if hasilm then
ilm.on_attach(client) ilm.on_attach(client)
end end
@ -74,6 +74,8 @@ M.on_attach = function(client, bufnr)
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
local config = require'navigator'.config_value
if config ~= nil then config.on_attach(client, bufnr) end
end end
M.setup = function(cfg) M.setup = function(cfg)

@ -26,6 +26,8 @@ local highlight = require "navigator.lspclient.highlight"
if lspconfig == nil then if lspconfig == nil then
error("loading lsp config") error("loading lsp config")
end end
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
local lsp_status_cfg = { local lsp_status_cfg = {
@ -154,8 +156,8 @@ local sqls_cfg = {
} }
} }
-- lua setup -- lua setup
local sumneko_root_path = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server" local sumneko_root_path = config.sumneko_root_path
local sumneko_binary = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server/bin/macOS/lua-language-server" local sumneko_binary = config.sumneko_binary
local lua_cfg = { local lua_cfg = {
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
@ -237,7 +239,6 @@ local function setup(user_opts)
end end
lsp_status_setup() lsp_status_setup()
for _, lspclient in ipairs(servers) do for _, lspclient in ipairs(servers) do
if lsp_status ~= nil and lsp_status.capabilitiess ~= nil then if lsp_status ~= nil and lsp_status.capabilitiess ~= nil then
lspconfig[lspclient].setup { lspconfig[lspclient].setup {
@ -257,11 +258,10 @@ local function setup(user_opts)
lspconfig.gopls.setup(golang_setup) lspconfig.gopls.setup(golang_setup)
lspconfig.sqls.setup(sqls_cfg) lspconfig.sqls.setup(sqls_cfg)
lspconfig.sumneko_lua.setup(lua_cfg) lspconfig.sumneko_lua.setup(lua_cfg)
lspconfig.clangd.setup(clang_cfg) lspconfig.clangd.setup(clang_cfg)
lspconfig.rust_analyzer.setup(rust_cfg) lspconfig.rust_analyzer.setup(rust_cfg)
end end
return {setup = setup, cap = cap} return {setup = setup, cap = cap}

Loading…
Cancel
Save