neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

commit 660f2b55eb039a37c6ba5368b3e535c302411c9d
parent 46c7ea88e5389d22bfd860f3af8692abb90b4dfe
Author: Tomas Nemec <owl@gtms.dev>
Date:   Tue, 19 Dec 2023 09:02:48 +0100

update

Diffstat:
Mafter/plugin/hardtime.lua | 2+-
Mafter/plugin/treesitter-context.lua | 4++--
Mcolors/tms.lua | 2+-
Mplugin/diagflow.lua | 52++++++++++++++++++++++++++++++++++++++++++++--------
4 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/after/plugin/hardtime.lua b/after/plugin/hardtime.lua @@ -2,4 +2,4 @@ if not pcall(require, 'hardtime') then return end --- require('hardtime').setup { disabled_filetypes = { 'qf', 'netrw', 'dirbuf', 'mason', 'query' } } +require('hardtime').setup { disabled_filetypes = { 'qf', 'netrw', 'dirbuf', 'mason', 'query' } } diff --git a/after/plugin/treesitter-context.lua b/after/plugin/treesitter-context.lua @@ -7,8 +7,8 @@ require'treesitter-context'.setup { -- max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. -- min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. line_numbers = true, - -- multiline_threshold = 20, -- Maximum number of lines to show for a single context - -- trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + multiline_threshold = 5, -- Maximum number of lines to show for a single context + -- trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' -- mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' -- -- Separator between context and content. Should be a single character string, like '-'. -- -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. diff --git a/colors/tms.lua b/colors/tms.lua @@ -348,8 +348,8 @@ vim.api.nvim_set_hl(0, 'DiagnosticHint', { fg = gui03, ctermfg = cterm03 }) -- vim.api.nvim_set_hl(0, group, {}) -- end -vim.api.nvim_set_hl(0, '@lsp.type.class', {}) vim.api.nvim_set_hl(0, '@lsp.type.enum', {}) +vim.api.nvim_set_hl(0, '@lsp.type.class', { link = 'Type' }) vim.api.nvim_set_hl(0, '@lsp.type.keyword', { link = 'Keyword' }) vim.api.nvim_set_hl(0, '@lsp.mod.annotation', { italic = true }) vim.api.nvim_set_hl(0, '@lsp.type.type', { bold = true }) diff --git a/plugin/diagflow.lua b/plugin/diagflow.lua @@ -16,6 +16,14 @@ -- } -- } local enable = true +local border_chars = { + top_left = '┌', + top_right = '┐', + bottom_left = '└', + bottom_right = '┘', + horizontal = '─', + vertical = '│', +} local ns = vim.api.nvim_create_namespace 'DiagflowHighlight' local severity_hl_map = { [vim.diagnostic.severity.ERROR] = 'DiagnosticError', @@ -37,6 +45,30 @@ local function get_padding(bufnr, winnr) return context_lines + 1 -- +1 for the underline end +local function create_boxed_text(text_lines) + if #text_lines == 0 then + return text_lines + end + + local max_length = 0 + for _, line in ipairs(text_lines) do + max_length = math.max(max_length, #line) + end + + local top_border = border_chars.top_left .. string.rep(border_chars.horizontal, max_length) .. border_chars.top_right + local bottom_border = border_chars.bottom_left .. string.rep(border_chars.horizontal, max_length) .. + border_chars.bottom_right + local boxed_lines = { top_border } + + for _, line in ipairs(text_lines) do + local padded_line = line .. string.rep(' ', max_length - #line) + table.insert(boxed_lines, border_chars.vertical .. padded_line .. border_chars.vertical) + end + + table.insert(boxed_lines, bottom_border) + return boxed_lines +end + local function clear(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1) @@ -70,14 +102,18 @@ local function render(diagnostics, bufnr) local padding = get_padding(bufnr, winnr) local line_offset = vim.fn.getwininfo(winnr)[1].topline - 1 + padding for _, diagnostic in ipairs(diagnostics) do - local hl_group = severity_hl_map[diagnostic.severity] - vim.api.nvim_buf_set_extmark(bufnr, ns, 0 + line_offset, 0, { - virt_text = { { diagnostic.message, hl_group } }, - virt_text_pos = 'right_align', - virt_text_hide = true, - strict = false, - }) - line_offset = line_offset + 1 + local message_lines = create_boxed_text(vim.split(diagnostic.message, '\n')) + for _, message in ipairs(message_lines) do + local hl_group = severity_hl_map[diagnostic.severity] + vim.api.nvim_buf_set_extmark(bufnr, ns, 0 + line_offset, 0, { + virt_text = { { message, hl_group } }, + virt_text_pos = 'right_align', + virt_text_hide = true, + strict = false, + priority = vim.highlight.priorities.user, + }) + line_offset = line_offset + 1 + end end end