From 626f17e5171639e2e374ccdbea6c7a0a16c0c938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Dudr?= Date: Fri, 11 Nov 2022 20:03:55 +0100 Subject: [PATCH] nvim --- dot_config/nvim/lua/configs/colors.lua | 93 +++++++++++++++++++++++- dot_config/nvim/lua/configs/lsp.lua | 6 +- dot_config/nvim/lua/configs/lualine.lua | 5 +- dot_config/nvim/lua/configs/neotree.lua | 8 +- dot_config/nvim/lua/configs/null-ls.lua | 1 + dot_config/nvim/lua/configs/packages.lua | 8 +- 6 files changed, 107 insertions(+), 14 deletions(-) diff --git a/dot_config/nvim/lua/configs/colors.lua b/dot_config/nvim/lua/configs/colors.lua index 64ec33d..fb0d347 100644 --- a/dot_config/nvim/lua/configs/colors.lua +++ b/dot_config/nvim/lua/configs/colors.lua @@ -124,11 +124,62 @@ local function normalizeTerminal() -- {{{ vim.g.terminal_color_15 = 15 end -- }}} +local function normalizeCmpKindHighlight() -- {{{ + vim.api.nvim_set_hl(0, 'CmpItemKindClass', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { link = 'Constant' }) + vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { link = 'Special' }) + vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { link = 'String' }) + vim.api.nvim_set_hl(0, 'CmpItemKindField', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindFile', { link = 'File' }) + vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { link = 'Directory' }) + vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { link = 'Function' }) + vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { link = 'Keyword' }) + vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { link = 'Function' }) + vim.api.nvim_set_hl(0, 'CmpItemKindModule', { link = 'Include' }) + vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { link = 'Special' }) + vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindText', { link = 'String' }) + vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { link = 'Identifier' }) + vim.api.nvim_set_hl(0, 'CmpItemKindValue', { link = 'String' }) + vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { link = 'Identifier' }) +end -- }}} + +local function copyFg(to, from, opts) + local cterm = vim.api.nvim_get_hl_by_name(from, false) + local gui = vim.api.nvim_get_hl_by_name(from, true) + local o = vim.tbl_extend('force', { ctermfg = cterm.foreground, fg = gui.foreground }, opts or {}) + vim.api.nvim_set_hl(0, to, o) +end + +local function clear(hl) + vim.api.nvim_set_hl(0, hl, {}) +end + +local function link(hl, to) + vim.api.nvim_set_hl(0, hl, { link = to }) +end + +local function normalizeTroubleHighlight() -- {{{ + clear('TroubleText') + copyFg('TroubleFoldIcon', 'CursorLineNr') + copyFg('TroubleLocation', 'LineNr') + copyFg('TroubleIndent', 'LineNr') + copyFg('TroubleSignInformation', 'DiagnosticSignInfo') + -- TroubleCount xxx links to TabLineSel + -- copyFg('TroubleError', 'DiagnosticError') + link('TroubleSignError', 'DiagnosticError') + link('TroubleSignWarning', 'DiagnosticSignWarn') + link('TroubleSignHint', 'DiagnosticHint') + + vim.api.nvim_set_hl(0, 'TroubleNormal', {}) +end -- }}} + local function customLinks() - local cterm = vim.api.nvim_get_hl_by_name('Normal', false) - local gui = vim.api.nvim_get_hl_by_name('Normal', true) - vim.api.nvim_set_hl(0, 'Function', { ctermfg = cterm.foreground, fg = gui.foreground }) - vim.api.nvim_set_hl(0, 'Operator', { ctermfg = cterm.foreground, fg = gui.foreground }) + copyFg('Function', 'Normal') + copyFg('Operator', 'Normal') end local augr = vim.api.nvim_create_augroup('config_colorscheme', {}); @@ -139,6 +190,25 @@ vim.api.nvim_create_autocmd('Colorscheme', { normalizeTSHighlight() customLinks() normalizeTerminal() + normalizeCmpKindHighlight() + normalizeTroubleHighlight() + local bla + end +}) + +local troublegr = vim.api.nvim_create_augroup('TroubleCursorline', { clear = true }) +vim.api.nvim_create_autocmd('WinEnter', { + group = troublegr, + pattern = '*Trouble', + callback = function() + vim.wo.cursorline = true + end +}) +vim.api.nvim_create_autocmd('WinLeave', { + group = troublegr, + pattern = '*Trouble', + callback = function() + vim.wo.cursorline = false end }) @@ -153,6 +223,21 @@ vim.api.nvim_create_autocmd('Colorscheme', { vim.api.nvim_set_hl(0, 'NeoTreeGitAdded', { link = 'GruvboxGreen' }) vim.api.nvim_set_hl(0, 'NeoTreeGitDeleted', { link = 'GruvboxRed' }) vim.api.nvim_set_hl(0, 'NeoTreeGitModified', { link = 'GruvboxOrange' }) + + vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { link = 'GruvboxAquaBold' }) + vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'GruvboxAquaBold' }) + + local tbg = vim.api.nvim_get_hl_by_name('GruvboxBg0', false) + local bg = vim.api.nvim_get_hl_by_name('GruvboxBg0', true) + local tfg = vim.api.nvim_get_hl_by_name('GruvboxGray', false) + local fg = vim.api.nvim_get_hl_by_name('GruvboxGray', true) + vim.api.nvim_set_hl(0, 'LineNr', + { fg = fg.foreground, + bg = bg.foreground, + ctermfg = tfg.foreground, + ctermbg = tbg.foreground, + underdotted = true + }) end }) diff --git a/dot_config/nvim/lua/configs/lsp.lua b/dot_config/nvim/lua/configs/lsp.lua index 08ee5da..e05814b 100644 --- a/dot_config/nvim/lua/configs/lsp.lua +++ b/dot_config/nvim/lua/configs/lsp.lua @@ -16,11 +16,15 @@ end local function on_attach(args) -- require "lsp_signature".on_attach() -- require'completion'.on_attach() - local bufnr = args.buf local client = vim.lsp.get_client_by_id(args.data.client_id) + + if (client.server_capabilities.documentSymbolProvider) then + require('nvim-navic').attach(client, bufnr) + end + -- Mappings. local opts = { noremap = true, silent = true, buffer = args.buf } diff --git a/dot_config/nvim/lua/configs/lualine.lua b/dot_config/nvim/lua/configs/lualine.lua index 1022ffa..b66d12d 100644 --- a/dot_config/nvim/lua/configs/lualine.lua +++ b/dot_config/nvim/lua/configs/lualine.lua @@ -1,6 +1,7 @@ local M = {} function M.setup() + local navic = require('nvim-navic') require 'lualine'.setup { options = { icons_enabled = true, @@ -26,7 +27,9 @@ function M.setup() lualine_z = {} }, tabline = {}, - winbar = {}, + winbar = { + lualine_c = { { navic.get_location, cond = navic.is_available } }, + }, inactive_winbar = {}, extensions = { 'neo-tree' } } diff --git a/dot_config/nvim/lua/configs/neotree.lua b/dot_config/nvim/lua/configs/neotree.lua index d6859fe..7d4fbba 100644 --- a/dot_config/nvim/lua/configs/neotree.lua +++ b/dot_config/nvim/lua/configs/neotree.lua @@ -55,9 +55,9 @@ function M.setup() git_status = { symbols = { -- Change type - added = '✚', -- or "✚", but this is redundant info if you use git_status_colors on the name - modified = '', -- or "", but this is redundant info if you use git_status_colors on the name - deleted = '✖', -- this can only be used in the git_status source + added = '', -- or "✚", but this is redundant info if you use git_status_colors on the name + modified = '', -- or "", but this is redundant info if you use git_status_colors on the name + deleted = '', -- this can only be used in the git_status source renamed = '', -- this can only be used in the git_status source -- Status type untracked = '', @@ -127,7 +127,7 @@ function M.setup() nesting_rules = {}, filesystem = { filtered_items = { - visible = false, -- when true, they will just be displayed differently than normal items + visible = true, -- when true, they will just be displayed differently than normal items hide_dotfiles = true, hide_gitignored = true, hide_hidden = true, -- only works on Windows for hidden files/directories diff --git a/dot_config/nvim/lua/configs/null-ls.lua b/dot_config/nvim/lua/configs/null-ls.lua index 6f75cac..c87a4d3 100644 --- a/dot_config/nvim/lua/configs/null-ls.lua +++ b/dot_config/nvim/lua/configs/null-ls.lua @@ -5,6 +5,7 @@ function M.setup() nls.setup({ debug = false, + temp_dir = vim.env.XDG_RUNTIME_DIR or '/tmp', sources = { nls.builtins.formatting.xmllint, nls.builtins.formatting.jq, diff --git a/dot_config/nvim/lua/configs/packages.lua b/dot_config/nvim/lua/configs/packages.lua index 07e8e55..c88b9a2 100644 --- a/dot_config/nvim/lua/configs/packages.lua +++ b/dot_config/nvim/lua/configs/packages.lua @@ -48,6 +48,9 @@ function M.setup() ]], false) end } + use { "SmiteshP/nvim-navic", requires = "neovim/nvim-lspconfig" +} + use { 'rafamadriz/friendly-snippets' } use 'hrsh7th/cmp-nvim-lsp-signature-help' @@ -149,10 +152,7 @@ function M.setup() requires = 'kyazdani42/nvim-web-devicons', cmd = 'TroubleToggle', keys = { 'n', 't TroubleToggle' }, - config = function() require('trouble').setup({ - mode = 'document_diagnostics' - }) - end + config = function() require('configs.trouble').setup() end } use { 'ziglang/zig.vim', ft = 'zig' }