Skip to content

Commit

Permalink
Fix line for show_header=false, add prefx_diagnostic config (nvimdev#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
smhc authored Nov 14, 2021
1 parent c884214 commit 746777b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ local saga = require 'lspsaga'
-- the related filetypes into this table
-- like server_filetype_map = {metals = {'sbt', 'scala'}}
-- server_filetype_map = {}
-- diagnostic_prefix_format = "%d. "

saga.init_lsp_saga {
your custom option here
Expand Down
8 changes: 5 additions & 3 deletions lua/lspsaga/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ local function show_diagnostics(opts, get_diagnostics)
local sorted_diagnostics = severity_sort and table.sort(diagnostics, comp_severity_asc) or diagnostics

for i, diagnostic in ipairs(sorted_diagnostics) do
local prefix = string.format("%d. ", i)
local prefix = string.format(config.diagnostic_prefix_format, i)
local hiname = diagnostic_highlights[diagnostic.severity]
or lsp.diagnostic._get_floating_severity_highlight_name(diagnostic.severity)
assert(hiname, "unknown severity: " .. tostring(diagnostic.severity))
Expand All @@ -114,8 +114,10 @@ local function show_diagnostics(opts, get_diagnostics)
fill = true,
pad_left = 3,
})
local truncate_line = wrap.add_truncate_line(wrap_message)
table.insert(wrap_message, 2, truncate_line)
if show_header then
local truncate_line = wrap.add_truncate_line(wrap_message)
table.insert(wrap_message, 2, truncate_line)
end

local content_opts = {
contents = wrap_message,
Expand Down
1 change: 1 addition & 0 deletions lua/lspsaga/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ saga.config_values = {
border_style = "single",
rename_prompt_prefix = "",
server_filetype_map = {},
diagnostic_prefix_format = "%d. ",
}

local extend_config = function(opts)
Expand Down
7 changes: 4 additions & 3 deletions lua/lspsaga/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ local function make_floating_popup_options(width, height, opts)
new_option.style = "minimal"
new_option.width = width
new_option.height = height
new_option.border = opts.border

if opts.relative ~= nil then
new_option.relative = opts.relative
Expand Down Expand Up @@ -148,8 +149,8 @@ function M.create_win_with_border(content_opts, opts)
local enter = content_opts.enter or false
local highlight = content_opts.highlight or "LspFloatWinBorder"
opts = opts or {}
opts = generate_win_opts(contents, opts)
opts.border = get_border_style(config.border_style, highlight)
local newopts = generate_win_opts(contents, opts)
newopts.border = opts.border or get_border_style(opts.border_style or config.border_style, highlight)

-- create contents buffer
local bufnr = api.nvim_create_buf(false, true)
Expand All @@ -166,7 +167,7 @@ function M.create_win_with_border(content_opts, opts)
api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
api.nvim_buf_set_option(bufnr, "buftype", "nofile")

local winid = api.nvim_open_win(bufnr, enter, opts)
local winid = api.nvim_open_win(bufnr, enter, newopts)
if filetype == "markdown" then
api.nvim_win_set_option(winid, "conceallevel", 2)
end
Expand Down

0 comments on commit 746777b

Please sign in to comment.