From 02e1c9be35e13e26b34bbfd680e18f3093ee2949 Mon Sep 17 00:00:00 2001 From: Alec Goncharow Date: Fri, 12 Jan 2024 19:51:00 -0500 Subject: ultimate yak shave: custom colorscheme --- .config/nvim/lua/autocomplete.lua | 8 ++-- .config/nvim/lua/bqf_conf.lua | 53 +++++++++++++++++++++++++ .config/nvim/lua/jabs_conf.lua | 69 +++++++++++++++++++++++++++++++++ .config/nvim/lua/ls.lua | 69 --------------------------------- .config/nvim/lua/lsp.lua | 26 +++++++------ .config/nvim/lua/lspsaga_conf.lua | 44 ++++++++++++++++++++- .config/nvim/lua/nerdcommenter_conf.lua | 7 ++++ .config/nvim/lua/plugins.lua | 22 +++++++---- .config/nvim/lua/settings.lua | 19 ++++++++- 9 files changed, 224 insertions(+), 93 deletions(-) create mode 100644 .config/nvim/lua/bqf_conf.lua create mode 100644 .config/nvim/lua/jabs_conf.lua delete mode 100644 .config/nvim/lua/ls.lua create mode 100644 .config/nvim/lua/nerdcommenter_conf.lua (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/autocomplete.lua b/.config/nvim/lua/autocomplete.lua index eef1625..8531258 100644 --- a/.config/nvim/lua/autocomplete.lua +++ b/.config/nvim/lua/autocomplete.lua @@ -15,11 +15,13 @@ cmp.setup({ end, }, experimental = { - ghost_text = true, + ghost_text = { + hl_group = "CmpGhostText", + }, }, window = { - completion = cmp.config.window.bordered({border = 'none'}), - documentation = cmp.config.window.bordered({border = 'none'}), + completion = cmp.config.window.bordered({ border = 'none' }), + documentation = cmp.config.window.bordered({ border = 'none' }), }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), diff --git a/.config/nvim/lua/bqf_conf.lua b/.config/nvim/lua/bqf_conf.lua new file mode 100644 index 0000000..35b681e --- /dev/null +++ b/.config/nvim/lua/bqf_conf.lua @@ -0,0 +1,53 @@ +local fn = vim.fn + +function _G.qftf(info) + local items + local ret = {} + -- The name of item in list is based on the directory of quickfix window. + -- Change the directory for quickfix window make the name of item shorter. + -- It's a good opportunity to change current directory in quickfixtextfunc :) + -- + -- local alterBufnr = fn.bufname('#') -- alternative buffer is the buffer before enter qf window + -- local root = getRootByAlterBufnr(alterBufnr) + -- vim.cmd(('noa lcd %s'):format(fn.fnameescape(root))) + -- + if info.quickfix == 1 then + items = fn.getqflist({ id = info.id, items = 0 }).items + else + items = fn.getloclist(info.winid, { id = info.id, items = 0 }).items + end + local limit = 31 + local fnameFmt1, fnameFmt2 = '%-' .. limit .. 's', '…%.' .. (limit - 1) .. 's' + local validFmt = '%s │%5d:%-3d│%s %s' + for i = info.start_idx, info.end_idx do + local e = items[i] + local fname = '' + local str + if e.valid == 1 then + if e.bufnr > 0 then + fname = fn.bufname(e.bufnr) + if fname == '' then + fname = '[No Name]' + else + fname = fname:gsub('^' .. vim.env.HOME, '~') + end + -- char in fname may occur more than 1 width, ignore this issue in order to keep performance + if #fname <= limit then + fname = fnameFmt1:format(fname) + else + fname = fnameFmt2:format(fname:sub(1 - limit)) + end + end + local lnum = e.lnum > 99999 and -1 or e.lnum + local col = e.col > 999 and -1 or e.col + local qtype = e.type == '' and '' or ' ' .. e.type:sub(1, 1):upper() + str = validFmt:format(fname, lnum, col, qtype, e.text) + else + str = e.text + end + table.insert(ret, str) + end + return ret +end + +vim.o.qftf = '{info -> v:lua._G.qftf(info)}' diff --git a/.config/nvim/lua/jabs_conf.lua b/.config/nvim/lua/jabs_conf.lua new file mode 100644 index 0000000..2b2ffff --- /dev/null +++ b/.config/nvim/lua/jabs_conf.lua @@ -0,0 +1,69 @@ +require 'jabs'.setup { + -- Options for the main window + position = { 'right', 'bottom' }, -- position = {'', ''} | left, center, right, + -- top, center, bottom + -- Default {'right', 'bottom'} + + relative = 'win', -- win, editor, cursor. Default win + clip_popup_size = true, -- clips the popup size to the win (or editor) size. Default true + + width = 50, -- default 50 + height = 10, -- default 10 + border = 'single', -- none, single, double, rounded, solid, shadow, (or an array or chars). Default shadow + + offset = { -- window position offset + top = 2, -- default 0 + bottom = 2, -- default 0 + left = 2, -- default 0 + right = 2, -- default 0 + }, + + sort_mru = true, -- Sort buffers by most recently used (true or false). Default false + split_filename = false, -- Split filename into separate components for name and path. Default false + split_filename_path_width = 20, -- If split_filename is true, how wide the column for the path is supposed to be, Default 0 (don't show path) + + -- Options for preview window + preview_position = 'top', -- top, bottom, left, right. Default top + preview = { + width = 70, -- default 70 + height = 30, -- default 30 + border = 'double', -- none, single, double, rounded, solid, shadow, (or an array or chars). Default double + }, + + -- Default highlights (must be a valid :highlight) + highlight = { + current = "Title", -- default StatusLine + hidden = "StatusLineNC", -- default ModeMsg + split = "WarningMsg", -- default StatusLine + alternate = "StatusLine" -- default WarningMsg + }, + + -- Default symbols + symbols = { + current = "C", -- default ]] + split = "S", -- default ]] + alternate = "A", -- default ]] + hidden = "H", -- default ﬘]] + locked = "L", -- default ]] + ro = "R", -- default ]] + edited = "E", -- default ]] + terminal = "T", -- default ]] + default_file = "D", -- Filetype icon if not present in nvim-web-devicons. Default ]] + terminal_symbol = ">_" -- Filetype icon for a terminal split. Default ]] + }, + + -- Keymaps + keymap = { + close = "x", -- Close buffer. Default D + jump = "", -- Jump to buffer. Default + h_split = "h", -- Horizontally split buffer. Default s + v_split = "v", -- Vertically split buffer. Default v + preview = "p", -- Open buffer preview. Default P + }, + + -- Whether to use nvim-web-devicons next to filenames + use_devicons = true -- true or false. Default true +} + + +Nmap('', ':JABSOpen') diff --git a/.config/nvim/lua/ls.lua b/.config/nvim/lua/ls.lua deleted file mode 100644 index 2361fda..0000000 --- a/.config/nvim/lua/ls.lua +++ /dev/null @@ -1,69 +0,0 @@ -require 'jabs'.setup { - -- Options for the main window - position = { 'right', 'bottom' }, -- position = {'', ''} | left, center, right, - -- top, center, bottom - -- Default {'right', 'bottom'} - - relative = 'win', -- win, editor, cursor. Default win - clip_popup_size = true, -- clips the popup size to the win (or editor) size. Default true - - width = 50, -- default 50 - height = 10, -- default 10 - border = 'shadow', -- none, single, double, rounded, solid, shadow, (or an array or chars). Default shadow - - offset = { -- window position offset - top = 2, -- default 0 - bottom = 2, -- default 0 - left = 2, -- default 0 - right = 2, -- default 0 - }, - - sort_mru = true, -- Sort buffers by most recently used (true or false). Default false - split_filename = false, -- Split filename into separate components for name and path. Default false - split_filename_path_width = 20, -- If split_filename is true, how wide the column for the path is supposed to be, Default 0 (don't show path) - - -- Options for preview window - preview_position = 'top', -- top, bottom, left, right. Default top - preview = { - width = 70, -- default 70 - height = 30, -- default 30 - border = 'double', -- none, single, double, rounded, solid, shadow, (or an array or chars). Default double - }, - - -- Default highlights (must be a valid :highlight) - highlight = { - current = "Title", -- default StatusLine - hidden = "StatusLineNC", -- default ModeMsg - split = "WarningMsg", -- default StatusLine - alternate = "StatusLine" -- default WarningMsg - }, - - -- Default symbols - symbols = { - current = "C", -- default ]] - split = "S", -- default ]] - alternate = "A", -- default ]] - hidden = "H", -- default ﬘]] - locked = "L", -- default ]] - ro = "R", -- default ]] - edited = "E", -- default ]] - terminal = "T", -- default ]] - default_file = "D", -- Filetype icon if not present in nvim-web-devicons. Default ]] - terminal_symbol = ">_" -- Filetype icon for a terminal split. Default ]] - }, - - -- Keymaps - keymap = { - close = "x", -- Close buffer. Default D - jump = "", -- Jump to buffer. Default - h_split = "h", -- Horizontally split buffer. Default s - v_split = "v", -- Vertically split buffer. Default v - preview = "p", -- Open buffer preview. Default P - }, - - -- Whether to use nvim-web-devicons next to filenames - use_devicons = true -- true or false. Default true -} - - -Nmap('', ':JABSOpen') diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index aa156b5..0c6fcd2 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -1,11 +1,10 @@ --- See `:help vim.diagnostic.*` for documentation on any of the below functions -local opts = { noremap = true, silent = true } +-- See `:help vim.diagnostic.*` for documentation on any of the below functiolocal opts = { noremap = true, silent = true } vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) -vim.lsp.set_log_level("debug") +vim.lsp.set_log_level("info") -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer @@ -18,11 +17,8 @@ local on_attach = function(client, bufnr) -- Mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'gk', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', '', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) vim.keymap.set('n', 'wl', function() @@ -30,11 +26,18 @@ local on_attach = function(client, bufnr) end, bufopts) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('v', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) - vim.keymap.set('v', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + --- following functions are now managed under ./lspsaga_conf.lua + -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + -- vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + -- vim.keymap.set('v', 'ca', vim.lsp.buf.code_action, bufopts) + -- vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) see ./lspsaga_conf.lua + -- vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + -- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + + -- vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + -- vim.keymap.set('v', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + -- disable lsp highlighting + -- client.server_capabilities.semanticTokensProvider = nil end -- Setup buffer-local keymaps / options for LSP buffers local capabilities = require("cmp_nvim_lsp").default_capabilities() @@ -65,6 +68,7 @@ local lspconfig = require('lspconfig') lspconfig.zls.setup({ on_attach = on_attach, capabilities = capabilities, + }) lspconfig.bashls.setup({ diff --git a/.config/nvim/lua/lspsaga_conf.lua b/.config/nvim/lua/lspsaga_conf.lua index c49c549..37dc583 100644 --- a/.config/nvim/lua/lspsaga_conf.lua +++ b/.config/nvim/lua/lspsaga_conf.lua @@ -2,7 +2,7 @@ vim.g.matchup_matchparen_offscreen = { method = {} } require('lspsaga').setup({ ui = { - border = 'none', + border = 'single', }, outline = { win_position = 'right', @@ -49,8 +49,50 @@ require('lspsaga').setup({ exec = '', }, }, + finder = { + max_height = 0.5, + left_width = 0.4, + methods = {}, + default = 'ref+imp', + layout = 'float', + silent = false, + filter = {}, + fname_sub = nil, + sp_inexist = false, + sp_global = false, + ly_botright = false, + keys = { + shuttle = '[w', + toggle_or_open = '', + vsplit = 's', + split = 'i', + tabe = 't', + tabnew = 'r', + quit = { 'q', '' }, + close = 'k', + }, + }, + definition = { + width = 0.6, + height = 0.5, + save_pos = false, + keys = { + edit = 'o', + vsplit = 'v', + split = 'i', + tabe = 't', + tabnew = 'n', + quit = { 'q', '' }, + close = 'k', + }, + }, }) Nmap('', ':Lspsaga outline') Nmap('', ':Lspsaga show_buf_diagnostics') Nmap('', ':Lspsaga code_action') +Nmap('ca', ':Lspsaga code_action') +Nmap('gr', ':Lspsaga finder ref') +Nmap('gi', ':Lspsaga finder imp') +Nmap('gd', ':Lspsaga goto_definition') +Nmap('gD', ':Lspsaga goto_type_definition') diff --git a/.config/nvim/lua/nerdcommenter_conf.lua b/.config/nvim/lua/nerdcommenter_conf.lua new file mode 100644 index 0000000..b5ac671 --- /dev/null +++ b/.config/nvim/lua/nerdcommenter_conf.lua @@ -0,0 +1,7 @@ +vim.g.NERDCreateDefaultMappings = 0 +vim.g.NERDSpaceDelims = 1 + +Nmap("cc", "NERDCommenterToggle"); +Vmap("cc", "NERDCommenterToggle"); +Nmap("cs", "NERDCommenterSexy"); +Nmap("cu", "NERDCommenterUncomment"); diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index c97cb15..4e10a81 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -3,7 +3,8 @@ return require('packer').startup(function() use 'wbthomason/packer.nvim' - use 'morhetz/gruvbox' + -- use 'morhetz/gruvbox' + -- use 'tjdevries/colorbuddy.nvim' use 'edkolev/tmuxline.vim' use 'romainl/vim-cool' @@ -19,13 +20,16 @@ return require('packer').startup(function() use 'RRethy/vim-illuminate' -- better quickfix buffer - use { 'kevinhwang91/nvim-bqf', - ft = 'qf', + use { 'kevinhwang91/nvim-bqf', ft = 'qf', config = function() - require('bqf').setup { - -- your configuration comes here - -- or leave it empty to use the default settings - } + -- Adapt fzf's delimiter in nvim-bqf + require('bqf').setup({ + filter = { + fzf = { + extra_opts = { '--bind', 'ctrl-o:toggle-all', '--delimiter', '│' } + } + } + }) end } use 'matbme/JABS.nvim' -- buffer switcher @@ -57,9 +61,9 @@ return require('packer').startup(function() use 'tpope/vim-eunuch' -- wrappers UNIX commands use 'tpope/vim-surround' -- surround characters shortcuts - use 'tpope/vim-vinegar' -- make explore better use 'tpope/vim-endwise' -- wisely add use 'tpope/vim-repeat' -- repeat for plugins + use 'tpope/vim-vinegar' -- make explore better use { 'prichrd/netrw.nvim', -- particles for ^ config = function() @@ -129,4 +133,6 @@ return require('packer').startup(function() } end } + -- auto close delimiters because lazy + use 'm4xshen/autoclose.nvim' end) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index bfc771c..36bab36 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -88,8 +88,20 @@ vim.cmd([[ au BufRead,BufNewFile *.slimbars set syntax=slim ]]) +vim.cmd([[ +" for debugging colorscheme +function! SynStack() + if !exists("*synstack") + return + endif + echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') +endfunc + +command! Synstack call SynStack() +]]) -vim.cmd('colorscheme gruvbox') + +vim.cmd('colorscheme yaks') vim.cmd([[ " ### Transparency ### hi Normal guibg=none ctermbg=none @@ -107,6 +119,11 @@ vim.o.wildmenu = true -- on TAB, complete options for system command vim.o.wildignore = 'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc' +-- sometimes shift is held down for too long while zoomer quitting +vim.api.nvim_create_user_command('Q', 'q', {}) +vim.api.nvim_create_user_command('Qa', 'qa', {}) +vim.api.nvim_create_user_command('QA', 'qa', {}) + -- rust format on save -- https://sharksforarms.dev/posts/neovim-rust/ -- cgit v1.2.3-70-g09d2