From dd12fee249eab862ef4149690826fce6ab96d2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Kmie=C4=87?= Date: Thu, 23 Mar 2023 08:56:45 +0100 Subject: [PATCH] Nvim: optimize config, change colorscheme to kanagawa --- .config/nvim/lua/core/mappings.lua | 8 + .config/nvim/lua/plugins/gitsigns.lua | 2 +- .config/nvim/lua/plugins/illuminate.lua | 10 +- .config/nvim/lua/plugins/init.lua | 7 +- .config/nvim/lua/plugins/lualine.lua | 227 ----------------------- .config/nvim/lua/plugins/null.lua | 16 ++ .config/nvim/lua/plugins/specs.lua | 22 +++ .config/nvim/lua/plugins/treesitter.lua | 11 +- .config/nvim/lua/plugins/virt-column.lua | 4 - 9 files changed, 64 insertions(+), 243 deletions(-) delete mode 100644 .config/nvim/lua/plugins/lualine.lua create mode 100644 .config/nvim/lua/plugins/null.lua create mode 100644 .config/nvim/lua/plugins/specs.lua delete mode 100644 .config/nvim/lua/plugins/virt-column.lua diff --git a/.config/nvim/lua/core/mappings.lua b/.config/nvim/lua/core/mappings.lua index e3a2aba..9915919 100644 --- a/.config/nvim/lua/core/mappings.lua +++ b/.config/nvim/lua/core/mappings.lua @@ -99,3 +99,11 @@ map('n', 'z', " WindowsMaximize") map('n', '_', " WindowsMaximizeVertically") map('n', '|', " WindowsMaximizeHorizontally") map('n', '=', "") + +-- specs +-- You can even bind it to search jumping and more, example: +vim.api.nvim_set_keymap('n', 'n', 'n:lua require("specs").show_specs()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'N', 'N:lua require("specs").show_specs()', { noremap = true, silent = true }) + +-- Or maybe you do a lot of screen-casts and want to call attention to a specific line of code: +vim.api.nvim_set_keymap('n', 'v', ':lua require("specs").show_specs({width = 97, winhl = "Search", delay_ms = 610, inc_ms = 21})', { noremap = true, silent = true }) diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua index 2a64f2e..57ed384 100644 --- a/.config/nvim/lua/plugins/gitsigns.lua +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -82,7 +82,7 @@ return { current_line_blame_opts = { virt_text = true, virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 1000, + delay = 5000, ignore_whitespace = true, }, current_line_blame_formatter_opts = { diff --git a/.config/nvim/lua/plugins/illuminate.lua b/.config/nvim/lua/plugins/illuminate.lua index 1b0dbd5..77699b4 100644 --- a/.config/nvim/lua/plugins/illuminate.lua +++ b/.config/nvim/lua/plugins/illuminate.lua @@ -1,10 +1,6 @@ return { 'nyngwang/murmur.lua', config = function() - --require('illuminate').configure({ - -- large_file_cutoff = 3000 - --}) - HIGHLIGHT = 'highlight' vim.api.nvim_create_augroup(HIGHLIGHT, { clear = true }) @@ -44,4 +40,10 @@ return { end }) end + -- 'tzachar/local-highlight.nvim', + -- config = function() + -- require('local-highlight').setup({ + -- file_types = {'python', 'cpp', 'rust', 'lua', 'cmake'} + -- }) + -- end } diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index 228240a..248b1a4 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -20,7 +20,6 @@ return {{ -- }}} -- Git integration {{{ -"lewis6991/gitsigns.nvim", "tpope/vim-fugitive", -- }}} @@ -77,14 +76,14 @@ return {{ "fenetikm/falcon", lazy = false, config = function() - -- vim.cmd([[ colorscheme falcon]]) + vim.cmd([[ colorscheme falcon]]) end }, { "rebelot/kanagawa.nvim", lazy = false, config = function() - vim.cmd([[ colorscheme kanagawa]]) + --vim.cmd([[ colorscheme kanagawa]]) end }, -- }}} @@ -107,8 +106,6 @@ return {{ "ziontee113/icon-picker.nvim", "cbochs/grapple.nvim", "shortcuts/no-neck-pain.nvim", -"edluffy/specs.nvim", -{ 'ruifm/gitlinker.nvim', dependencies = 'nvim-lua/plenary.nvim'}, --'jinzhongjia/PS_manager.nvim', -- }}} }} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua deleted file mode 100644 index da1c8f6..0000000 --- a/.config/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,227 +0,0 @@ -return { - 'nvim-lualine/lualine.nvim', - config = function() - -- Eviline config for lualine - -- Author: shadmansaleh - -- Credit: glepnir - local lualine = require('lualine') - - -- Color table for highlights - -- stylua: ignore - local colors = { - bg = '#202328', - fg = '#bbc2cf', - yellow = '#ECBE7B', - cyan = '#008080', - darkblue = '#081633', - green = '#98be65', - orange = '#FF8800', - violet = '#a9a1e1', - magenta = '#c678dd', - blue = '#51afef', - red = '#ec5f67', - } - - - local conditions = { - buffer_not_empty = function() - return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 - end, - hide_in_width = function() - return vim.fn.winwidth(0) > 80 - end, - check_git_workspace = function() - local filepath = vim.fn.expand('%:p:h') - local gitdir = vim.fn.finddir('.git', filepath .. ';') - return gitdir and #gitdir > 0 and #gitdir < #filepath - end, - } - - -- Config - local config = { - options = { - -- Disable sections and component separators - component_separators = '', - section_separators = '', - theme = { - -- We are going to use lualine_c an lualine_x as left and - -- right section. Both are highlighted by c theme . So we - -- are just setting default looks o statusline - normal = { c = { fg = colors.fg, bg = colors.bg } }, - inactive = { c = { fg = colors.fg, bg = colors.bg } }, - }, - }, - sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - -- These will be filled later - lualine_c = {}, - lualine_x = {}, - }, - inactive_sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - lualine_c = {}, - lualine_x = {}, - }, - } - - -- Inserts a component in lualine_c at left section - local function ins_left(component) - table.insert(config.sections.lualine_c, component) - end - - -- Inserts a component in lualine_x ot right section - local function ins_right(component) - table.insert(config.sections.lualine_x, component) - end - - ins_left { - function() - return '▊' - end, - color = { fg = colors.blue }, -- Sets highlighting of component - padding = { left = 0, right = 1 }, -- We don't need space before this - } - - ins_left { - -- mode component - function() - return '' - end, - color = function() - -- auto change color according to neovims mode - local mode_color = { - n = colors.red, - i = colors.green, - v = colors.blue, - [''] = colors.blue, - V = colors.blue, - c = colors.magenta, - no = colors.red, - s = colors.orange, - S = colors.orange, - [''] = colors.orange, - ic = colors.yellow, - R = colors.violet, - Rv = colors.violet, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ['r?'] = colors.cyan, - ['!'] = colors.red, - t = colors.red, - } - return { fg = mode_color[vim.fn.mode()] } - end, - padding = { right = 1 }, - } - - ins_left { - -- filesize component - 'filesize', - cond = conditions.buffer_not_empty, - } - - ins_left { - 'filename', - cond = conditions.buffer_not_empty, - color = { fg = colors.magenta, gui = 'bold' }, - } - - ins_left { 'location' } - - ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } - - ins_left { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ' }, - diagnostics_color = { - color_error = { fg = colors.red }, - color_warn = { fg = colors.yellow }, - color_info = { fg = colors.cyan }, - }, - } - - -- Insert mid section. You can make any number of sections in neovim :) - -- for lualine it's any number greater then 2 - ins_left { - function() - return '%=' - end, - } - - ins_left { - -- Lsp server name . - function() - local msg = 'No Active Lsp' - local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') - local clients = vim.lsp.get_active_clients() - if next(clients) == nil then - return msg - end - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return client.name - end - end - return msg - end, - icon = ' LSP:', - color = { fg = '#ffffff', gui = 'bold' }, - } - - -- Add components to right sections - ins_right { - 'o:encoding', -- option component same as &encoding in viml - fmt = string.upper, -- I'm not sure why it's upper case either ;) - cond = conditions.hide_in_width, - color = { fg = colors.green, gui = 'bold' }, - } - - ins_right { - 'fileformat', - fmt = string.upper, - icons_enabled = true, -- I think icons are cool but Eviline doesn't have them. sigh - color = { fg = colors.green, gui = 'bold' }, - } - - ins_right { - 'branch', - icon = '', - color = { fg = colors.violet, gui = 'bold' }, - } - - ins_right { - 'diff', - -- Is it me or the symbol for modified us really weird - symbols = { added = ' ', modified = '柳 ', removed = ' ' }, - diff_color = { - added = { fg = colors.green }, - modified = { fg = colors.orange }, - removed = { fg = colors.red }, - }, - cond = conditions.hide_in_width, - } - - ins_right { - function() - return '▊' - end, - color = { fg = colors.blue }, - padding = { left = 1 }, - } - - -- Now don't forget to initialize lualine - lualine.setup(config) - end -} diff --git a/.config/nvim/lua/plugins/null.lua b/.config/nvim/lua/plugins/null.lua new file mode 100644 index 0000000..2b86c45 --- /dev/null +++ b/.config/nvim/lua/plugins/null.lua @@ -0,0 +1,16 @@ +return { + 'jose-elias-alvarez/null-ls.nvim', + config = function() + null_ls = require("null-ls") + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.completion.spell, + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.diagnostics.cmake_lint, + null_ls.builtins.diagnostics.codespell, + null_ls.builtins.diagnostics.hadolint, + null_ls.builtins.hover.dictionary}, + }) + end +} diff --git a/.config/nvim/lua/plugins/specs.lua b/.config/nvim/lua/plugins/specs.lua new file mode 100644 index 0000000..e8f440e --- /dev/null +++ b/.config/nvim/lua/plugins/specs.lua @@ -0,0 +1,22 @@ +return { + 'edluffy/specs.nvim', + config = function() + require('specs').setup{ + show_jumps = true, + min_jump = 30, + popup = { + delay_ms = 0, -- delay before popup displays + inc_ms = 10, -- time increments used for fade/resize effects + blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend + width = 10, + winhl = "PMenu", + fader = require('specs').linear_fader, + resizer = require('specs').shrink_resizer + }, + ignore_filetypes = {}, + ignore_buftypes = { + nofile = true, + }, + } + end +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index bbff4d8..440978c 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -15,6 +15,13 @@ return { ts.setup { highlight = { enable = true, + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, additional_vim_regex_highlighting = false, }, ensure_installed = { @@ -24,7 +31,7 @@ return { "bibtex", "c", "cmake", - "comment", + --"comment", "cpp", "devicetree", "diff", @@ -90,6 +97,6 @@ return { }, } vim.opt.foldmethod = "expr" - vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + -- vim.opt.foldexpr = "nvim_treesitter#foldexpr()" end } diff --git a/.config/nvim/lua/plugins/virt-column.lua b/.config/nvim/lua/plugins/virt-column.lua deleted file mode 100644 index 41f15a1..0000000 --- a/.config/nvim/lua/plugins/virt-column.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'lukas-reineke/virt-column.nvim', - config = true -}