update window height and width preset

pull/25/head
ray-x 3 years ago
parent 95b45a6cf6
commit c5fe79d6df

@ -181,13 +181,16 @@ Nondefault configuration example:
```lua ```lua
require.'navigator'.setup({ require.'navigator'.setup({
debug = false, -- log output not implemented debug = false, -- log output
code_action_icon = " ", code_action_icon = " ",
width = 0.75, -- number of cols for the floating window width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- preview window size, 0.3 by default 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', border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"}, -- border style, can be one of 'none', 'single', 'double',
-- 'shadow', or a list of chars which defines the border -- 'shadow', or a list of chars which defines the border
on_attach = nil, on_attach = function(client, bufnr)
-- your hook
end,
-- put a on_attach of your own here, e.g -- put a on_attach of your own here, e.g
-- function(client, bufnr) -- function(client, bufnr)
-- -- the on_attach will be called at end of navigator on_attach -- -- the on_attach will be called at end of navigator on_attach
@ -205,7 +208,7 @@ require.'navigator'.setup({
diagnostic_head = '🐛', diagnostic_head = '🐛',
diagnostic_head_severity_1 = "🈲", diagnostic_head_severity_1 = "🈲",
-- refer to lua/navigator.lua for more icons setups -- refer to lua/navigator.lua for more icons setups
} },
lsp = { lsp = {
format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc) format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
tsserver = { tsserver = {

@ -3,7 +3,7 @@ _NgConfigValues = {
debug = false, -- log output not implemented debug = false, -- log output not implemented
width = 0.6, -- valeu of cols TODO allow float e.g. 0.6 width = 0.6, -- valeu of cols TODO allow float e.g. 0.6
preview_height = 0.35, preview_height = 0.35,
height = nil, height = 0.35,
default_mapping = true, default_mapping = true,
on_attach = nil, on_attach = nil,
-- function(client, bufnr) -- function(client, bufnr)
@ -46,9 +46,9 @@ _NgConfigValues = {
associated = "🤝", associated = "🤝",
namespace = "🚀", namespace = "🚀",
type = "", type = "",
field = "🏈", field = "🏈"
}, },
treesitter_defult = "🌲", treesitter_defult = "🌲"
} }
} }

@ -50,7 +50,7 @@ function M._preview_location(opts) -- location, width, pos_x, pos_y
syntax = syntax, syntax = syntax,
width = opts.width, width = opts.width,
height = display_range['end'].line - display_range.start.line + 1, height = display_range['end'].line - display_range.start.line + 1,
preview_height = opts.preview_height, preview_height = opts.height or opts.preview_height,
pos_x = opts.offset_x, pos_x = opts.offset_x,
pos_y = opts.offset_y, pos_y = opts.offset_y,
range = opts.range, range = opts.range,
@ -113,13 +113,16 @@ function M.new_list_view(opts)
local wwidth = api.nvim_get_option("columns") local wwidth = api.nvim_get_option("columns")
local loc = "top_center" local loc = "top_center"
local width = math.floor(wwidth * 0.75)
local mwidth = _NgConfigValues.width
local width = math.floor(wwidth * mwidth)
if config.width ~= nil and config.width > 0.3 and config.width < 0.99 then if config.width ~= nil and config.width > 0.3 and config.width < 0.99 then
width = math.floor(wwidth * config.width) width = math.floor(wwidth * config.width)
end end
width = math.min(opts.width or 120, width) width = math.min(120, width)
opts.width = width local wheight = math.floor(1 + api.nvim_get_option("lines")
local wheight = config.height or math.floor(api.nvim_get_option("lines") * 0.8) * (_NgConfigValues.height + _NgConfigValues.preview_height))
local pheight = math.floor(api.nvim_get_option("lines") * _NgConfigValues.preview_height)
local prompt = opts.prompt or false local prompt = opts.prompt or false
if opts.rawdata then if opts.rawdata then
data = items data = items
@ -137,8 +140,7 @@ function M.new_list_view(opts)
prompt = true prompt = true
end end
local lheight = math.min(#data, math.floor(wheight / 2)) local lheight = math.min(#data, math.floor(wheight * _NgConfigValues.height))
local pheight = math.min(wheight - lheight, math.floor(wheight / 2))
local r, _ = top_center(lheight, width) local r, _ = top_center(lheight, width)

@ -96,7 +96,7 @@ local function set_mapping(user_opts)
local range_fmt = false local range_fmt = false
local doc_fmt = false local doc_fmt = false
local ccls = false local ccls = false
log(vim.lsp.buf_get_clients(0)) -- log(vim.lsp.buf_get_clients(0))
for _, value in pairs(vim.lsp.buf_get_clients(0)) do for _, value in pairs(vim.lsp.buf_get_clients(0)) do
if value == nil or value.resolved_capabilities == nil then if value == nil or value.resolved_capabilities == nil then
return return
@ -108,7 +108,7 @@ local function set_mapping(user_opts)
range_fmt = true range_fmt = true
end end
log("override ccls", value.config) -- log("override ccls", value.config)
if value.config.name == "ccls" then if value.config.name == "ccls" then
ccls = true ccls = true

@ -39,7 +39,8 @@ local function ref_hdlr(err, api, locations, num, bufnr)
local ft = vim.api.nvim_buf_get_option(bufnr, "ft") local ft = vim.api.nvim_buf_get_option(bufnr, "ft")
local wwidth = vim.api.nvim_get_option("columns") local wwidth = vim.api.nvim_get_option("columns")
width = math.min(width + 30, 120, math.floor(wwidth * 0.8)) local mwidth = _NgConfigValues.width
width = math.min(width + 30, 120, math.floor(wwidth * mwidth))
gui.new_list_view({ gui.new_list_view({
items = items, items = items,
ft = ft, ft = ft,

Loading…
Cancel
Save