diff options
| author | Robert Günzler <r@gnzler.io> | 2021-02-20 21:27:26 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-04-26 02:09:43 +0200 |
| commit | 1996ef15613f2d4773017128bba1a719a1b63a19 (patch) | |
| tree | aa291b56947f0f710c96c62758990de3b2939bba /.vim/lua | |
| parent | 30451238df36d238fea816f01ca987853c6562a5 (diff) | |
Move to lua based vimrc
Diffstat (limited to '.vim/lua')
| -rw-r--r-- | .vim/lua/conf/diagnostic.lua | 21 | ||||
| -rw-r--r-- | .vim/lua/conf/telescope.lua | 75 | ||||
| -rw-r--r-- | .vim/lua/hardmode.lua | 38 | ||||
| -rw-r--r-- | .vim/lua/init.lua | 4 | ||||
| -rw-r--r-- | .vim/lua/line.lua | 146 | ||||
| -rw-r--r-- | .vim/lua/plugins.lua | 201 | ||||
| -rw-r--r-- | .vim/lua/plugins/_colorizer.lua | 8 | ||||
| -rw-r--r-- | .vim/lua/plugins/_completion.lua | 17 | ||||
| -rw-r--r-- | .vim/lua/plugins/_git-messenger.lua | 3 | ||||
| -rw-r--r-- | .vim/lua/plugins/_goyo.lua | 9 | ||||
| -rw-r--r-- | .vim/lua/plugins/_indent-guides.lua | 4 | ||||
| -rw-r--r-- | .vim/lua/plugins/_limelight.lua | 7 | ||||
| -rw-r--r-- | .vim/lua/plugins/_lsp.lua (renamed from .vim/lua/conf/lsp.lua) | 57 | ||||
| -rw-r--r-- | .vim/lua/plugins/_markdown.lua | 9 | ||||
| -rw-r--r-- | .vim/lua/plugins/_signify.lua | 6 | ||||
| -rw-r--r-- | .vim/lua/plugins/_telescope.lua | 99 | ||||
| -rw-r--r-- | .vim/lua/plugins/_treesitter.lua (renamed from .vim/lua/conf/treesitter.lua) | 2 | ||||
| -rw-r--r-- | .vim/lua/plugins/_ultisnips.lua | 4 | ||||
| -rw-r--r-- | .vim/lua/plugins/_vimtex.lua | 8 | ||||
| -rw-r--r-- | .vim/lua/split_term/init.lua | 46 | ||||
| -rw-r--r-- | .vim/lua/utils.lua | 35 |
21 files changed, 410 insertions, 389 deletions
diff --git a/.vim/lua/conf/diagnostic.lua b/.vim/lua/conf/diagnostic.lua index 4fd5047..fe80fff 100644 --- a/.vim/lua/conf/diagnostic.lua +++ b/.vim/lua/conf/diagnostic.lua @@ -1,9 +1,12 @@ -vim.g.diagnostic_enable_virtual_text = 1 -vim.g.diagnostic_trimmed_virtual_text = '40' -vim.g.diagnostic_insert_delay = 1 -vim.api.nvim_command('nnoremap <silent> c[ <cmd>PrevDiagnosticCycle<cr>') -vim.api.nvim_command('nnoremap <silent> c] <cmd>NextDiagnosticCycle<cr>') +local g = vim.g +local cmd = vim.api.nvim_command + +g.diagnostic_enable_virtual_text = 1 +g.diagnostic_trimmed_virtual_text = '40' +g.diagnostic_insert_delay = 1 +cmd('nnoremap <silent> c[ <cmd>PrevDiagnosticCycle<cr>') +cmd('nnoremap <silent> c] <cmd>NextDiagnosticCycle<cr>') vim.fn.sign_define("LspDiagnosticsErrorSign", {text="✘", texthl="LspDiagnosticsError"}) @@ -11,7 +14,7 @@ vim.fn.sign_define("LspDiagnosticsWarningSign", {text="‼", texthl="LspDiagnost vim.fn.sign_define("LspDiagnosticsInformationSign", {text="i", texthl="LspDiagnosticsInformation"}) vim.fn.sign_define("LspDiagnosticsHintSign", {text="☛",texthl="LspDiagnosticsHint"}) -vim.api.nvim_command('highlight link LspDiagnosticsError Error') -vim.api.nvim_command('highlight link LspDiagnosticsWarning WarningMsg') -vim.api.nvim_command('highlight link LspDiagnosticsInformation Todo') -vim.api.nvim_command('highlight link LspDiagnosticsHint Question') +cmd('highlight link LspDiagnosticsError Error') +cmd('highlight link LspDiagnosticsWarning WarningMsg') +cmd('highlight link LspDiagnosticsInformation Todo') +cmd('highlight link LspDiagnosticsHint Question') diff --git a/.vim/lua/conf/telescope.lua b/.vim/lua/conf/telescope.lua deleted file mode 100644 index e1145c2..0000000 --- a/.vim/lua/conf/telescope.lua +++ /dev/null @@ -1,75 +0,0 @@ --- config for telescope.nvim -local telescope = require('telescope') -local finders = require('telescope.finders') -local pickers = require('telescope.pickers') -local previewers = require('telescope.previewers') -local make_entry = require('telescope.make_entry') -local sorters = require('telescope.sorters') - -telescope.setup{ - defaults = { - borderchars = {'─', '│', '─', '│', '┌', '┐', '┘', '└'}, - winblend = 3, - layout_strategy = 'flex', - } -} - -vim.api.nvim_set_keymap('n', ';f', "<cmd>lua require'telescope.builtin'.find_files{}<cr>", - {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', ';g', "<cmd>lua require'telescope.builtin'.live_grep{}<cr>", - {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', ';r', "<cmd>lua require'telescope.builtin'.lsp_references{}<cr>", - {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', ';q', "<cmd>lua require'telescope.builtin'.quickfix{}<cr>", - {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', ';l', "<cmd>lua require'telescope.builtin'.loclist{}<cr>", - {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', ';b', "<cmd>lua require'telescope.builtin'.buffers{}<cr>", - {noremap=true, silent=true}) --- vim.api.nvim_set_keymap('n', ';h', "<cmd>lua require'conf.telescope'.home{}<cr>", --- {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', ';w', "<cmd>lua require'conf.telescope'.wiki{}<cr>", - {noremap=true, silent=true}) - -local M = {} -M.fzf = function(opts) - opts = opts or {} - if opts.cwd then - opts.cwd = vim.fn.expand(opts.cwd) - end - local cmd = {'fd', '--type', 'f', '--no-ignore', '--absolute-path'} - if opts.extensions then - for _, ext in ipairs(opts.extensions) do - table.insert(cmd, '--extension') - table.insert(cmd, ext) - end - end - if opts.exclude then - for _, excl in ipairs(opts.exclude) do - table.insert(cmd, '--exclude') - table.insert(cmd, excl) - end - end - pickers.new(opts, { - prompt = opts.prompt or "FZF", - finder = finders.new_oneshot_job(cmd, opts), - previewer = previewers.cat.new(opts), - sorter = sorters.get_fuzzy_file(), - }):find() -end - -M.wiki = function() - return M.fzf { - prompt = 'WIKI', - cwd = '~/wiki', - extensions = {'md'}, - exclude = {'_templates/*'} - } -end --- M.home = function() --- return M.fzf { --- prompt = 'HOME', --- cwd = '~', --- } --- end -return M diff --git a/.vim/lua/hardmode.lua b/.vim/lua/hardmode.lua new file mode 100644 index 0000000..ed7d4ac --- /dev/null +++ b/.vim/lua/hardmode.lua @@ -0,0 +1,38 @@ +-- hard mode means we're not using the arrow keys! +-- map them to more useful actions instead +-- https://coderoncode.com/posts/vim-is-the-perfect-ide + +local cmd = vim.cmd +local u = require('utils') + +local bail = ':silent! echohl ErrorMsg | echo "HARD MODE: hjkl operation only" | echohl None<CR>' + +u.map('n', 'R<up>', ':resize +2<CR>') +u.map('n', 'R<down>', ':resize -2<CR>') +u.map('n', 'R<left>', ':vertical resize +2<CR>') +u.map('n', 'R<right>', ':vertical resize +2<CR>') + +u.map('n', 'W<up>', ':wincmd k<CR>') +u.map('n', 'W<down>', ':wincmd j<CR>') +u.map('n', 'W<left>', ':wincmd h<CR>') +u.map('n', 'W<right>', ':wincmd l<CR>') + +u.map('n', 'Wm<up>', ':wincmd K<CR>') +u.map('n', 'Wm<down>', ':wincmd J<CR>') +u.map('n', 'Wm<left>', ':wincmd H<CR>') +u.map('n', 'Wm<right>', ':wincmd L<CR>') + +u.map('n', '<up>', bail) +u.map('n', '<down>', bail) +u.map('n', '<left>', bail) +u.map('n', '<right>', bail) + +u.map('v', '<up>', bail) +u.map('v', '<down>', bail) +u.map('v', '<left>', bail) +u.map('v', '<right>', bail) + +u.map('i', '<up>', '<esc>' .. bail) +u.map('i', '<down>', '<esc>' .. bail) +u.map('i', '<left>', '<esc>' .. bail) +u.map('i', '<right>', '<esc>' .. bail) diff --git a/.vim/lua/init.lua b/.vim/lua/init.lua deleted file mode 100644 index 0397b28..0000000 --- a/.vim/lua/init.lua +++ /dev/null @@ -1,4 +0,0 @@ --- init lua - -require 'plugins' -require 'conf.diagnostic' diff --git a/.vim/lua/line.lua b/.vim/lua/line.lua deleted file mode 100644 index 278782f..0000000 --- a/.vim/lua/line.lua +++ /dev/null @@ -1,146 +0,0 @@ --- statusline - -local gl = require('galaxyline') -local gls = gl.section -local gcolors = require('galaxyline.colors') - -local colors = { - blue = '#5fafd7', - orange = '#d7875f', - purple = '#af87d7', - yellow = '#d7af5f', - - black = '#1c1c1c', - grey_dim = '#3a3a3a', - grey_dimmer = '#262626', - white = '#d0d0d0', - white_dim = '#bdc0ba', -} - -local style = { - left = { - sep = ' ', - sep_hl = {colors.white, colors.black}, - }, - right = { - hl = {colors.white,colors.grey_dimmer}, - sep = ' ', - sep_hl = {colors.grey_dim, colors.grey_dimmer}, - } -} - -local empty_buffer = function() - if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then - return true - end - return false -end - -local space = function() return ' ' end - -gls.left[1] = { - ViMode = { - provider = function() - local m = vim.fn.mode() - if m == 'n' then - gcolors.set_highlight('GalaxyViMode', {colors.white, colors.grey_dim, 'bold'}) - elseif m == 'i' then - gcolors.set_highlight('GalaxyViMode', {colors.black, colors.blue, 'bold'}) - elseif m == 'v' or m == 'V' or m == 'CTRL-V' then - gcolors.set_highlight('GalaxyViMode', {colors.black, colors.purple, 'bold'}) - elseif m == 's' or m == 'S' or m == 'CTRL-S' then - gcolors.set_highlight('GalaxyViMode', {colors.black, '#ff0000', 'bold'}) - elseif m == 'R' or m == 'Rc' or m == 'Rv' or m == 'Rx' then - gcolors.set_highlight('GalaxyViMode', {colors.black, colors.orange, 'bold'}) - elseif m == 'c' then - gcolors.set_highlight('GalaxyViMode', {colors.yellow, colors.grey_dim, 'bold,italic'}) - end - return ' ' .. m:gsub("^%l*$", string.upper) .. ' ' - end, - separator = style.left.sep, - separator_highlight = style.left.sep_hl, - }, -} - -gls.left[2] = { - FileName = { - provider = function() - local file = vim.fn.expand('%:t') - if vim.fn.empty(file) == 1 then return '' end - if vim.bo.readonly then - return file .. ' ' - end - if vim.o.modifiable then - if vim.bo.modified then - return file .. ' +' - end - end - return file .. ' ' - end, - condition = empty_buffer, - highlight = {colors.white,colors.grey_dimmer}, - separator = style.left.sep, - separator_highlight = style.left.sep_hl, - } -} - --- ########################################################## -- - -gls.right[1] = { - Indent = { - provider = function() - local res = vim.o.expandtab and '→' or '␣' - return res - .. ' ' - .. 'ts=' .. vim.o.tabstop - .. ' ' - .. 'sw=' .. vim.o.shiftwidth - end, - highlight = style.right.hl, - }, -} - -gls.right[2] = { - BufNum = { - icon = '% ', - provider = function() - local nbufs = #vim.fn.getbufinfo({buflisted = 1}) - local res = vim.fn.bufnr('%') .. '(' .. nbufs .. ')' - if vim.fn.tabpagenr() > 1 then - res = res .. ':' .. vim.fn.tabpagenr() - end - return res - end, - highlight = style.right.hl, - separator = style.right.sep, - separator_highlight = style.right.sep_hl, - }, -} - -gls.right[3] = { - LineColumn = { - icon = ' ', - provider = 'LineColumn', - highlight = style.right.hl, - separator = style.right.sep, - separator_highlight = style.right.sep_hl, - }, -} - -gls.right[4] = { - LinePercent = { - provider = 'LinePercent', - highlight = style.right.hl, - separator = style.right.sep, - separator_highlight = style.right.sep_hl, - } -} - -gls.right[5] = { - BufferType = { - provider = function() return ' ' .. vim.bo.filetype .. ' ' end, - highlight = {colors.white,colors.grey_dim,'bold'}, - -- separator = style.right.sep, - -- separator_highlight = style.right.sep_hl, - } -} diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index 0ccfb05..4830b4b 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -1,24 +1,27 @@ -- load by calling `lua require('plugins')` from your init.vim +local cmd = vim.cmd +local g = vim.g +local u = require('utils') function disable_distribution_plugins() - vim.g.loaded_gzip = 1 - vim.g.loaded_tar = 1 - vim.g.loaded_tarPlugin = 1 - vim.g.loaded_zip = 1 - vim.g.loaded_zipPlugin = 1 - vim.g.loaded_getscript = 1 - vim.g.loaded_getscriptPlugin = 1 - vim.g.loaded_vimball = 1 - vim.g.loaded_vimballPlugin = 1 - vim.g.loaded_matchit = 1 - -- vim.g.loaded_matchparen = 1 - vim.g.loaded_2html_plugin = 1 - vim.g.loaded_logiPat = 1 - vim.g.loaded_rrhelper = 1 - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - vim.g.loaded_netrwSettings = 1 - vim.g.loaded_netrwFileHandlers = 1 + g.loaded_gzip = 1 + g.loaded_tar = 1 + g.loaded_tarPlugin = 1 + g.loaded_zip = 1 + g.loaded_zipPlugin = 1 + g.loaded_getscript = 1 + g.loaded_getscriptPlugin = 1 + g.loaded_vimball = 1 + g.loaded_vimballPlugin = 1 + g.loaded_matchit = 1 + -- g.loaded_matchparen = 1 + g.loaded_2html_plugin = 1 + g.loaded_logiPat = 1 + g.loaded_rrhelper = 1 + g.loaded_netrw = 1 + g.loaded_netrwPlugin = 1 + g.loaded_netrwSettings = 1 + g.loaded_netrwFileHandlers = 1 end -- enable to bootstrap packer from ~/.local/share/nvim/site/pack/packer/opt/packer.nvim @@ -31,112 +34,124 @@ return require'packer'.startup(function() -- manage packer itself use {'wbthomason/packer.nvim'} - use {'mhinz/vim-signify'} -- git status in the sign column + -- git status in the sign column + use {'mhinz/vim-signify', + config = "require('plugins._signify')" + } + use {'tpope/vim-commentary'} -- auto-comment using `gcc` use {'cohama/lexima.vim'} -- auto-close parens, brackets, etc. use {'tpope/vim-surround'} -- edit surroundings in pairs - -- use {'itchyny/lightline.vim'} -- lightweight status bar - use {'glepnir/galaxyline.nvim', - branch = 'main', - config=function() require 'line' end} - use {'neomake/neomake'} -- async job runner - use {'sbdchd/neoformat'} -- async code formatter + -- use {'neomake/neomake'} -- async job runner + -- use {'sbdchd/neoformat'} -- async code formatter use {'justinmk/vim-dirvish'} -- folder browser - use {'justinmk/vim-sneak'} -- powerful missing vim motions - - use { 'neovim/nvim-lspconfig', - requires = {'nvim-lua/completion-nvim'}, -- , 'nvim-lua/diagnostic-nvim'}, - config=function() require'conf.lsp' end} + use {'justinmk/vim-sneak', + config = "vim.g['sneak#label'] = true" + } - use { 'steelsojka/completion-buffers' } - -- config = function() - -- vim.api.nvim_command("autocmd BufEnter * require'completion'.on_attach()") - -- end} + use {'neovim/nvim-lspconfig', + requires = { + {'nvim-lua/completion-nvim', + requires = {'steelsojka/completion-buffers'}, + config = "require('plugins._completion')"}, + 'kosayoda/nvim-lightbulb', + }, + config = "require('plugins._lsp')" + } - use { 'nvim-treesitter/nvim-treesitter', + use {'nvim-treesitter/nvim-treesitter', requires = { 'nvim-lua/completion-nvim', 'nvim-treesitter/completion-treesitter', 'nvim-treesitter/nvim-treesitter-refactor', }, - config=function() require'conf.treesitter' end} - - use { 'nvim-lua/telescope.nvim', - requires = {'nvim-lua/popup.nvim', 'nvim-lua/plenary.nvim'}, - config=function() require'conf.telescope' end} + config = "require('plugins._treesitter')" + } + + use {'nvim-telescope/telescope.nvim', + requires = { + 'nvim-lua/popup.nvim', + 'nvim-lua/plenary.nvim', + -- telescope plugins: + 'nvim-telescope/telescope-fzf-writer.nvim', + }, + config = "require('plugins._telescope')" + } + + -- polyfill for some missing stuff + use {'tjdevries/astronauta.nvim'} -- snippets use {'SirVer/ultisnips', - requires = {'honza/vim-snippets'}} - - -- interactive finder / dispatcher - -- use {'liuchengxu/vim-clap', - -- run = ':Clap install-binary!'} + requires = {'honza/vim-snippets'}, + config = "require('plugins._ultisnips')" + } - use {'junegunn/vim-easy-align', - cmd = {'EasyAlign'}} + use {'junegunn/vim-easy-align'} -- use {'tpope/vim-sleuth'} -- detect indentation - use {'nathanaelkane/vim-indent-guides'} -- show indentation levels + use {'nathanaelkane/vim-indent-guides', + config = "require('plugins._indent-guides')" + } + use {'tpope/vim-repeat'} -- extend '.' to plugins - use {'liuchengxu/vista.vim'} -- sidebar populated by lsp, ctags, etc. use {'sgur/vim-editorconfig'} -- implements editorconfig in vimscript - -- use 'rhysd/conflict-marker.vim' use {'michaeljsmith/vim-indent-object'} -- adds indentation text-objects - use {'kshenoy/vim-signature'} -- toggle, display and navigate marks - -- highlight color codes + use {'kshenoy/vim-signature', disable = true} -- toggle, display and navigate marks use {'norcalli/nvim-colorizer.lua', - config=function() - require'colorizer'.setup(nil, { - name = true; - RRGGBB = true; - RRGGBBAA = false; - rgb_fn = true; - hsl_fn = true; - mode = 'background'; - }) - end} - use {'rhysd/git-messenger.vim'} -- git-blame in a popup - use {'kassio/neoterm'} + config = "require('plugins._colorizer')" + } + + use {'rhysd/git-messenger.vim', + config = "require('plugins._git-messenger')" + } + + use {'rhysd/conflict-marker.vim', disable = true} + -- use {'liuchengxu/vista.vim'} -- sidebar populated by lsp, ctags, etc. + use {'kassio/neoterm', disable = true} -- languages -- NOTE: these should only be loaded when they are required... - -- use {'rhysd/vim-grammarous', ft = {'markdown', 'latex', 'tex'}} - use {'lervag/vimtex', ft = {'latex', 'tex'}} - use {'plasticboy/vim-markdown', ft = {'markdown'}} - use {'masukomi/vim-markdown-folding', ft = {'markdown'}} - -- easy html editing - use {'mattn/emmet-vim', ft = {'html'}} - -- use {'valloric/matchtagalways', ft = {'html', 'vue', 'xml'}} -- visually match HTML tags enclosing cursor location - -- use {'ledger/vim-ledger', ft = {'ledger'}, - -- requires = { - -- 'tpope/vim-speeddating', -- easy time/date incrementing - -- 'vim-scripts/utl.vim'}} -- follow links/urls - + -- use {'rhysd/vim-grammarous', + -- ft = {'markdown', 'latex', 'tex'} + -- } + use {'lervag/vimtex', + ft = {'latex', 'tex'}, + config = "require('plugins._vimtex')" + } + use {'plasticboy/vim-markdown', + ft = {'markdown'}, + config = "require('plugins._markdown')" + } + use {'masukomi/vim-markdown-folding', + ft = {'markdown'} + } + use {'jjo/vim-cue', + ft = {'cue'} + } use {'gentoo/gentoo-syntax'} - use {'jjo/vim-cue'} -- multi-language support with lazy loading -- NOTE: put language specific plugs before this to avoid conflicsts use {'sheerun/vim-polyglot'} -- minimal ux - use {'junegunn/goyo.vim', cmd = 'Goyo'} -- hide ui clutter - use {'junegunn/limelight.vim', cmd = 'Limelight'} -- dims colors - -- use 'equalsraf/neovim-gui-shim' - - -- colorschemes - use {'NLKNguyen/papercolor-theme'} - -- use {'cideM/yui'} - use {'ayu-theme/ayu-vim'} - -- use {'rktjmp/lush.nvim', - -- config=function() require'conf.colors' end} - - use {'dstein64/vim-startuptime'} + use {'junegunn/goyo.vim', + cmd = 'Goyo', + config = "require('plugins._goyo')" + } + use {'junegunn/limelight.vim', + cmd = 'Limelight', + config = "require('plugins._limelight')" + } + + use {'rktjmp/lush.nvim', + disable = true, + config="require('plugins._lush')"} + + -- vim config debugging + use {'dstein64/vim-startuptime', disable = true} -- local - -- use {'~/devel/projects/nihon-theme/vim'} - -- use {'~/devel/projects/vim-orgdown'} - use {'~/.vim/devel/obsidian.nvim'} - use {'~/.vim/devel/vim-github-link'} + use {'~/devel/upstream/github.com/knsh14/vim-github-link'} end) diff --git a/.vim/lua/plugins/_colorizer.lua b/.vim/lua/plugins/_colorizer.lua new file mode 100644 index 0000000..7b6f678 --- /dev/null +++ b/.vim/lua/plugins/_colorizer.lua @@ -0,0 +1,8 @@ +require('colorizer').setup(nil, { + name = true; + RRGGBB = true; + RRGGBBAA = false; + rgb_fn = true; + hsl_fn = true; + mode = 'background'; +}) diff --git a/.vim/lua/plugins/_completion.lua b/.vim/lua/plugins/_completion.lua new file mode 100644 index 0000000..8a4a92e --- /dev/null +++ b/.vim/lua/plugins/_completion.lua @@ -0,0 +1,17 @@ +local g = vim.g +local u = require('utils') + +g.completion_enable_auto_popup = true +g.completion_enable_auto_signature = true +g.completion_enable_auto_paren = false +g.completion_confirm_key = '<tab>' +g.completion_enable_snippet = 'UltiSnips' +g.completion_auto_change_source = true +g.completion_chain_complete_list = { + {complete_items = {'lsp', 'snippet', 'buffers', 'ts', 'path'}}, + {mode = 'file'}, +} + +u.augroup('completion', { + {'BufEnter', '*', 'lua require("completion").on_attach()'}, +}) diff --git a/.vim/lua/plugins/_git-messenger.lua b/.vim/lua/plugins/_git-messenger.lua new file mode 100644 index 0000000..ea1c271 --- /dev/null +++ b/.vim/lua/plugins/_git-messenger.lua @@ -0,0 +1,3 @@ +-- vim.g.git_messenger_include_diff = false +vim.g.git_messenger_always_into_popup = true +vim.g.git_messenger_close_on_cursor_moved = true diff --git a/.vim/lua/plugins/_goyo.lua b/.vim/lua/plugins/_goyo.lua new file mode 100644 index 0000000..e18d2ba --- /dev/null +++ b/.vim/lua/plugins/_goyo.lua @@ -0,0 +1,9 @@ +vim.g.goyo_width = 120 +vim.g.goyo_height = 90 +vim.g.goyo_linenr = false +require('utils').augroup('goyo_hooks', { + {'User', 'GoyoEnter', 'set laststatus=0 scrolloff=999'}, + {'User', 'GoyoEnter', 'Limelight'}, + {'User', 'GoyoLeave', 'set laststatus=2 scrolloff=5'}, + {'User', 'GoyoLeave', 'Limelight!'}, +}) diff --git a/.vim/lua/plugins/_indent-guides.lua b/.vim/lua/plugins/_indent-guides.lua new file mode 100644 index 0000000..eb3c4aa --- /dev/null +++ b/.vim/lua/plugins/_indent-guides.lua @@ -0,0 +1,4 @@ +vim.g.indent_guides_enable_on_vim_startup = false +vim.g.indent_guides_start_level = 2 +vim.g.indent_guides_color_change_percent = 2 +vim.g.indent_guides_guide_size = 1 diff --git a/.vim/lua/plugins/_limelight.lua b/.vim/lua/plugins/_limelight.lua new file mode 100644 index 0000000..b77fdfc --- /dev/null +++ b/.vim/lua/plugins/_limelight.lua @@ -0,0 +1,7 @@ +vim.g.limelight_conceal_ctermfg = 'gray' +vim.g.limelight_conceal_ctermbg = 'none' +vim.g.limelight_conceal_guifg = '#828282' +vim.g.limelight_conceal_guibg = 'none' +vim.g.limelight_default_coefficient = 0.5 +vim.g.limelight_paragraph_span = 1 +vim.g.limelight_priority = -1 diff --git a/.vim/lua/conf/lsp.lua b/.vim/lua/plugins/_lsp.lua index 4249de5..9d98aca 100644 --- a/.vim/lua/conf/lsp.lua +++ b/.vim/lua/plugins/_lsp.lua @@ -1,21 +1,33 @@ -- lsp config -local lsp = require 'lspconfig' -local util = require 'lspconfig.util' +local lsp = require('lspconfig') +local util = require('lspconfig.util') +local u = require('utils') -local function my_attach(client) +-- https://github.com/kosayoda/nvim-lightbulb +require('nvim-lightbulb').update_lightbulb { + sign = { + enabled = true, + priority = 10, + }, + float = { + enabled = true, + text = '', + win_opts = {}, + }, +} + +local my_attach = function(client) -- attach completion require 'completion'.on_attach(client) - -- do lsp mappings - vim.fn.nvim_buf_set_keymap(0, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', - {noremap=true, silent=true}) - vim.fn.nvim_buf_set_keymap(0, 'n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<cr>', - {noremap=true, silent=true}) - vim.fn.nvim_buf_set_keymap(0, 'n', 'grr', '<cmd>lua vim.lsp.buf.rename()<cr>', - {noremap=true, silent=true}) - vim.fn.nvim_buf_set_keymap(0, 'i', '<c-h>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', - {noremap=true, silent=true}) + -- lsp mappings + u.map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>') + u.map(0, 'n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<cr>') + u.map(0, 'n', 'grr', '<cmd>lua vim.lsp.buf.rename()<cr>') + u.map(0, 'i', '<c-h>', '<cmd>lua vim.lsp.buf.signature_help()<cr>') + u.map(0, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>') + u.map(0, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>') -- nnoremap <silent> gD <cmd> lua vim.lsp.buf.declaration()<CR> -- nnoremap <silent> gd <cmd> lua vim.lsp.buf.definition()<CR> @@ -40,12 +52,27 @@ lsp.gopls.setup{ } lsp.sumneko_lua.setup{ - cmd = { 'lua-language-server' }; on_attach = my_attach; + cmd = { 'lua-language-server' }; + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = {'vim'}, + }, + workspace = { + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + } + } + } + }, } lsp.rust_analyzer.setup{ - cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' }, on_attach = my_attach, - + cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' }, } diff --git a/.vim/lua/plugins/_markdown.lua b/.vim/lua/plugins/_markdown.lua new file mode 100644 index 0000000..c773d50 --- /dev/null +++ b/.vim/lua/plugins/_markdown.lua @@ -0,0 +1,9 @@ +g.vim_markdown_folding_disabled = true +g.vim_markdown_math = true +g.vim_markdown_frontmatter = true +g.vim_markdown_json_frontmatter = true +g.vim_markdown_toml_frontmatter = true +g.vim_markdown_folding_level = 2 +g.vim_markdown_strikethrough = true +g.vim_markdown_auto_insert_bullets = true +g.vim_markdown_new_list_item_indent = false diff --git a/.vim/lua/plugins/_signify.lua b/.vim/lua/plugins/_signify.lua new file mode 100644 index 0000000..a91ecb6 --- /dev/null +++ b/.vim/lua/plugins/_signify.lua @@ -0,0 +1,6 @@ +vim.g.signify_sign_change = '~' +require('utils').map('n', ']h', '<plug>(signify-next-hunk)', {silent=false}) +require('utils').map('n', '[h', '<plug>(signify-prev-hunk)') +vim.cmd('hi SignifySignChange guibg=NONE ctermbg=NONE') +vim.cmd('hi SignifySignAdd guibg=NONE ctermbg=NONE') +vim.cmd('hi SignifySignDelete guibg=NONE ctermbg=NONE') diff --git a/.vim/lua/plugins/_telescope.lua b/.vim/lua/plugins/_telescope.lua new file mode 100644 index 0000000..d4f9b89 --- /dev/null +++ b/.vim/lua/plugins/_telescope.lua @@ -0,0 +1,99 @@ +-- telescope.nvim et al config + +local u = require('utils') + +local M = {} + +-- TELESCOPE config -- {{{ +require('telescope').setup{ + defaults = { + -- vimgrep_arguments = { + -- 'rg', + -- '--color=never', + -- '--no-heading', + -- '--with-filename', + -- '--line-number', + -- '--column', + -- '--smart-case' + -- }, + + prompt_prefix = ' >', + borderchars = {'─', '│', '─', '│', '┌', '┐', '┘', '└'}, + winblend = 0, + preview_cutoff = 120, + + layout_strategy = 'flex', + + file_previewer = require('telescope.previewers').vim_buffer_cat_new, + grep_previewer = require('telescope.previewers').vim_buffer_vimgrep_new, + qflist_previewer = require('telescope.previewers').vim_buffer_qflist_new, + + extensions = { + fzf_writer = { + use_highlighter = true, + minimum_grep_characters = 4, + shorten_path = true, + } + } + } +} +-- }}} + +-- LOCAL finders -- {{{ +M.wrap = function(opts) + opts = opts or {} + my_opts = require('telescope.themes').get_dropdown({ width = 110 }) + return vim.tbl_deep_extend("force", my_opts, opts) +end + +M.live_grep = function() + require('telescope').extensions.fzf_writer.staged_grep(M.wrap()) +end + +M.repo_search = function() + require('telescope').extensions.fzf_writer.files(M.wrap({ + previewer = false, + cwd = require('lspconfig.util').root_pattern('.git')(vim.fn.expand('%:p')), + })) +end + +M.wiki = function() + require('telescope').extensions.fzf_writer.files(M.wrap({ + previewer = false, + cwd = '~/wiki/', + })) +end + +M.devel = function() + require('telescope').extensions.fzf_writer.files(M.wrap({ + previewer = false, + cwd = '~/devel/', + })) +end +-- }}} + +-- MAPPINGS -- {{{ + +u.map('n', ';g', "<cmd>lua require('plugins._telescope').live_grep()<cr>") +u.map('n', ';r', "<cmd>lua require('plugins._telescope').repo_search()<cr>") +-- u.map('n', ';w', "<cmd>lua require('plugins._telescope').wiki()<cr>") +u.map('n', ';d', "<cmd>lua require('plugins._telescope').devel()<cr>") + +local mapbuiltin = function(key, fn, previewer) + opts = (not previewer and '{ previewer = false }') or '{}' + u.map('n', key, "<cmd>lua require('telescope.builtin')."..fn.."(require('plugins._telescope').wrap("..opts.."))<cr>") +end + +mapbuiltin(';f', 'fd', true) +mapbuiltin(';q', 'quickfix') +mapbuiltin(';l', 'loclist') +mapbuiltin(';b', 'buffers') +mapbuiltin(';t', 'tags') +mapbuiltin(';lr', 'lsp_references') +mapbuiltin(';la', 'lsp_code_actions') +mapbuiltin(';lw', 'lsp_workspace_symbols') +mapbuiltin(';c', 'command_history') + +-- }}} + +return M diff --git a/.vim/lua/conf/treesitter.lua b/.vim/lua/plugins/_treesitter.lua index fed55e1..ef24286 100644 --- a/.vim/lua/conf/treesitter.lua +++ b/.vim/lua/plugins/_treesitter.lua @@ -1,5 +1,5 @@ -require 'nvim-treesitter.configs'.setup { +require('nvim-treesitter.configs').setup { ensure_installed = { "c", "c_sharp", "javascript", "lua", "bash" }, highlight = { enable = false, diff --git a/.vim/lua/plugins/_ultisnips.lua b/.vim/lua/plugins/_ultisnips.lua new file mode 100644 index 0000000..f2a6f6e --- /dev/null +++ b/.vim/lua/plugins/_ultisnips.lua @@ -0,0 +1,4 @@ +-- vim.g.UltiSnipsListSnippets = "<c-tab>" +vim.g.UltiSnipsExpandTrigger = "<Tab>" +vim.g.UltiSnipsJumpForwardTrigger = "<c-n>" +vim.g.UltiSnipsJumpBackwardTrigger = "<c-p>" diff --git a/.vim/lua/plugins/_vimtex.lua b/.vim/lua/plugins/_vimtex.lua new file mode 100644 index 0000000..2a3d550 --- /dev/null +++ b/.vim/lua/plugins/_vimtex.lua @@ -0,0 +1,8 @@ +vim.g.tex_flavor = 'latex' +vim.g.vimtex_compiler_enabled = 1 +vim.g.vimtex_compiler_method = 'tectonic' +vim.g.vimtex_compiler_tectonic = "{'executable': 'tectonic'}" +vim.g.vimtex_view_method = 'zathura' +-- vim.g.vimtex_view_zathura_check_libsynctex = false +-- vim.g.vimtex_view_use_temp_files = true +-- vim.g.vimtex_view_forward_search_on_start = false diff --git a/.vim/lua/split_term/init.lua b/.vim/lua/split_term/init.lua deleted file mode 100644 index 7dcb044..0000000 --- a/.vim/lua/split_term/init.lua +++ /dev/null @@ -1,46 +0,0 @@ -local spt = {} - -function spt:create() - self = { - height = 80, - buf_nr = nil, - win_id = nil, - visible = false, - } -end - -function spt:show() - vim.eval('botright new') - if self.buf_nr then - vim.eval('buffer ' .. self.buf_nr) - else - vim.termopen(self.exec, { detach=0 }) - self.buf_nr = vim.bufnr('%') - end -end - -function spt:open() -end - -function spt:hide() -end - -function spt:close() - local force = true - vim.api.nvim_win_close(self.win_id, force) - self.buf_nr = nil - self.win_id = nil -end - -function spt_toggle() - if spt.win_id then - if spt.visible then - spt:hide() - else - spt:show() - end - else - spt:create() - spt:show() - end -end diff --git a/.vim/lua/utils.lua b/.vim/lua/utils.lua new file mode 100644 index 0000000..ab7793f --- /dev/null +++ b/.vim/lua/utils.lua @@ -0,0 +1,35 @@ +-- utils.lua + +local M = {} + +-- crutch until https://github.com/neovim/neovim/pull/13479 +M.opt = function(scope, key, val) + local scopes = {o = vim.o, b = vim.bo, w = vim.wo} + if not ( scope and key and val ) then return end + scopes[scope][key] = val + if scope ~= 'o' then scopes['o'][key] = val end +end + +M.map = function(mode, lhs, rhs, opts) + if not ( mode and lhs and rhs ) then return end + local o = {noremap = true, silent = true} + if opts then o = vim.tbl_extend('force', o, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, o) +end + +M.augroup = function(name, autocmds) + if not ( name and autocmds ) then return end + vim.cmd('augroup ' .. name) + vim.cmd('autocmd!') + for _, au in ipairs(autocmds) do + vim.cmd('autocmd ' .. table.concat(au, ' ')) + end + vim.cmd('augroup END') +end + +M.def = function(name, cmd, ...) + local opts = table.concat((... or {}), ' ') + vim.cmd('command! ' .. opts .. ' ' .. name .. ' ' .. cmd) +end + +return M |