aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua')
-rw-r--r--.config/nvim/lua/autocomplete.lua8
-rw-r--r--.config/nvim/lua/bqf_conf.lua53
-rw-r--r--.config/nvim/lua/jabs_conf.lua (renamed from .config/nvim/lua/ls.lua)2
-rw-r--r--.config/nvim/lua/lsp.lua26
-rw-r--r--.config/nvim/lua/lspsaga_conf.lua44
-rw-r--r--.config/nvim/lua/nerdcommenter_conf.lua7
-rw-r--r--.config/nvim/lua/plugins.lua22
-rw-r--r--.config/nvim/lua/settings.lua19
8 files changed, 156 insertions, 25 deletions
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({
['<C-b>'] = 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/ls.lua b/.config/nvim/lua/jabs_conf.lua
index 2361fda..2b2ffff 100644
--- a/.config/nvim/lua/ls.lua
+++ b/.config/nvim/lua/jabs_conf.lua
@@ -9,7 +9,7 @@ require 'jabs'.setup {
width = 50, -- default 50
height = 10, -- default 10
- border = 'shadow', -- none, single, double, rounded, solid, shadow, (or an array or chars). Default shadow
+ border = 'single', -- none, single, double, rounded, solid, shadow, (or an array or chars). Default shadow
offset = { -- window position offset
top = 2, -- default 0
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', '<space>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', '<space>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', '<leader><leader>', vim.lsp.buf.hover, bufopts)
- vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
@@ -30,11 +26,18 @@ local on_attach = function(client, bufnr)
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
- vim.keymap.set('v', '<space>ca', vim.lsp.buf.code_action, bufopts)
- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
- vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
- vim.keymap.set('v', '<space>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', '<space>ca', vim.lsp.buf.code_action, bufopts)
+ -- vim.keymap.set('v', '<space>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', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
+ -- vim.keymap.set('v', '<space>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 = '<CR>',
},
},
+ 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 = '<CR>',
+ vsplit = 's',
+ split = 'i',
+ tabe = 't',
+ tabnew = 'r',
+ quit = { 'q', '<ESC>' },
+ close = '<C-c>k',
+ },
+ },
+ definition = {
+ width = 0.6,
+ height = 0.5,
+ save_pos = false,
+ keys = {
+ edit = '<C-c>o',
+ vsplit = '<C-c>v',
+ split = '<C-c>i',
+ tabe = '<C-c>t',
+ tabnew = '<C-c>n',
+ quit = { 'q', '<ESC>' },
+ close = '<C-c>k',
+ },
+ },
})
Nmap('<c-e>', ':Lspsaga outline<CR>')
Nmap('<c-d>', ':Lspsaga show_buf_diagnostics<CR>')
Nmap('<c-a>', ':Lspsaga code_action<CR>')
+Nmap('<leader>ca', ':Lspsaga code_action<CR>')
+Nmap('gr', ':Lspsaga finder ref<CR>')
+Nmap('gi', ':Lspsaga finder imp<CR>')
+Nmap('gd', ':Lspsaga goto_definition<CR>')
+Nmap('gD', ':Lspsaga goto_type_definition<CR>')
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("<leader>cc", "<Plug>NERDCommenterToggle");
+Vmap("<leader>cc", "<Plug>NERDCommenterToggle");
+Nmap("<leader>cs", "<Plug>NERDCommenterSexy");
+Nmap("<leader>cu", "<Plug>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/