diff --git a/bootstrap/packages.txt b/bootstrap/packages.txt index e62d0ca..42f4c61 100644 --- a/bootstrap/packages.txt +++ b/bootstrap/packages.txt @@ -76,6 +76,7 @@ jabref-latest jiq jpdftweak jq +lazygit libdvdcss licenses linux-firmware diff --git a/nvim/.config/nvim/after/ftplugin/pandoc.vim b/nvim/.config/nvim/after/ftplugin/pandoc.vim deleted file mode 100644 index 9a57633..0000000 --- a/nvim/.config/nvim/after/ftplugin/pandoc.vim +++ /dev/null @@ -1 +0,0 @@ -:Prose diff --git a/nvim/.config/nvim/after/plugin/prose.vim b/nvim/.config/nvim/after/plugin/prose.vim deleted file mode 100644 index 258591c..0000000 --- a/nvim/.config/nvim/after/plugin/prose.vim +++ /dev/null @@ -1,15 +0,0 @@ -" PROSE: function to automatically enables markdown plugins for md & txt files -function! s:Prose() - " PLUGIN: vim-textobj-sentence - " enable extended sentence textobject use on md and plaintext files - call textobj#sentence#init() - IndentBlanklineDisable - " hide the markdown cruft - setlocal conceallevel=2 - setlocal foldlevel=3 -endfunction - -" invoke it manually by writing :Prose -" or, it will get automatically sourced for certain filetypes in -" after/ftplugin directory -command! -nargs=0 Prose call s:Prose() diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index f073c2f..3001dfc 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -3,36 +3,40 @@ local augroup = require("helpers.augroup") local api = vim.api -require('base.settings') -require('base.look') -require('base.plugins') +require('settings') +require('plugins') +require('look') +require('maps') + +-- Highlight whatever is being yanked +augroup({ + { + 'TextYankPost', '*', + 'silent! lua require"vim.highlight".on_yank{timeout=500}' + } +}, 'highlightyanks') + +-- Compile on plugin edits +augroup({{'BufWritePost', 'plugins.lua', 'PackerCompile'}}, 'compilepackages') -- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to augroup({ - { 'BufNewFile,BufRead', '/dev/shm/gopass.*', 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' }, - { 'BufNewFile,BufRead', '/dev/shm/pass.?*/?*.txt', 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' }, - { 'BufNewFile,BufRead', '$TMPDIR/pass.?*/?*.txt', 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' }, - { 'BufNewFile,BufRead', '/tmp/pass.?*/?*.txt', 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' } + { + 'BufNewFile,BufRead', '/dev/shm/gopass.*', + 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' + }, { + 'BufNewFile,BufRead', '/dev/shm/pass.?*/?*.txt', + 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' + }, { + 'BufNewFile,BufRead', '$TMPDIR/pass.?*/?*.txt', + 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' + }, { + 'BufNewFile,BufRead', '/tmp/pass.?*/?*.txt', + 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' + } }, 'passnoleak') -- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330) -augroup({ - { 'VimEnter', '*', 'silent exec "!kill -s SIGWINCH $PPID"' } -}, 'fixsize') +augroup({{'VimEnter', '*', 'silent exec "!kill -s SIGWINCH $PPID"'}}, 'fixsize') - --- TODO from here on starts stuff we want to convert into new settings format as well -api.nvim_exec('runtime! keys/*.vim', false) -api.nvim_exec('runtime colorscheme.vim', false) api.nvim_exec('runtime abbrev.vim', false) - -local plugin_configs = { - '_lsp', - '_treesitter', - '_indentation', - '_telescope' -} --- load lua plugin configurations -for _, f in ipairs(plugin_configs) do - require(f) -end diff --git a/nvim/.config/nvim/keys/maps.vim b/nvim/.config/nvim/keys/maps.vim deleted file mode 100644 index 69e2e2f..0000000 --- a/nvim/.config/nvim/keys/maps.vim +++ /dev/null @@ -1,257 +0,0 @@ -" The general ideas behind these mappings: -" -" * Leader prefix is the generally preferred way to map new things, however -" only for those that affect all of vim -" -" * Localleader prefix is used for mappings which only affect single buffers, -" in other words mostly filetype specific mappings -" -" many of these mapping ideas come from Tom Ryder who has them nicely -" documented - -" backspace to switch to alternate (last) buffer -" this may have to be adjusted / removed to let wiki.vim use BS for navigation -nnoremap - -" since u undoes, would it not make sense that U redoes? -nnoremap U - -" d-motion puts the last 'deleted' thing into the default register to paste; -" use D-motion to truly delete something into nothingness and keep whatever -" you want in your register, ready to paste -nnoremap D "_d - -" I don't particularly need ex mode (at least, yet) but faster macro access -" is nice -nnoremap Q @ - -" stronger versions of left,right - move all the way to beginning/end of line -nnoremap H ^ -nnoremap L $ - -" when in softwrapped files, allow moving through the visible lines with j/k -" but when prepending a number jump *exactly* as many lines, wrapped or not -" This makes relative linenumbers much more useful in prose docs since they -" are always exactly correct -nnoremap k (v:count == 0 ? 'gk' : 'k') -nnoremap j (v:count == 0 ? 'gj' : 'j') - -" move around between matching brackets with tab -nnoremap % -nnoremap % - -" when in insertion mode, C-u uppercases the current word, C-l lowercases it, -inoremap gUiw`]a -inoremap guiw`]a - -" let me save stuff as sudo when I forget to call vim with it -cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! - -" yank filename to f buffer -nnoremap yf :let @f = expand("%") - -" repeat the last substitute command with all its flags preserved -noremap & - \ :&& -ounmap & -sunmap & - -" bracket pairings to go to the next/previous of: -" (works with count prefixes) -" -" Argument list -nnoremap [a - \ :previous -nnoremap ]a - \ :next -" Buffers -nnoremap [b - \ :bprevious -nnoremap ]b - \ :bnext -" Quickfix list -nnoremap [c - \ :cprevious -nnoremap ]c - \ :cnext -" Location list -nnoremap [l - \ :lprevious -nnoremap ]l - \ :lnext - -" set our leader key to space since with hjkl, space is largely useless -let mapleader = "\" -" maps the leader for buffer local mappings -" since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does -" not do too many useful things and can be taken up as localleader -let maplocalleader = "," - -" If we mapped localleader to comma, we can still get to its original function -" by douple-tapping it. -if maplocalleader ==# ',' - noremap ,, , - sunmap ,, -endif - -" remove search highlights by pressing space+/ - the key for searching the -" first place -nnoremap / :noh - -" split buffers vertically/horizontally with the leader \ or - (mirrors my -" tmux setup) -nnoremap - :sp -nnoremap \ :vsp -" 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) -nnoremap t :vsp . -" open actual new tab with leader-T -nnoremap T :tabedit . - -" select the whole buffer with -a -nnoremap a ggVG - -" CONFIG EDITING -" quickly edit vimrc with leader+V -nnoremap V :vsp $MYVIMRC -" automatically source the vimrc file whenever it is saved (causes slowdown -" when done in MANY successions) -" au BufWritePost init.vim so ~/.config/nvim/init.vim -" source vimrc with keystroke combination -nnoremap VV :source $MYVIMRC - -" PLUGIN: vim-sneak -map f Sneak_f -map F Sneak_F -map t Sneak_t -map T Sneak_T - -" PLUGIN: Vifm.vim -" open/close file tree with leader-e -nnoremap e :Vifm getcwd() -" open current file tree with current file directory -nnoremap E :Vifm - -" PLUGIN: Telescope GLOBAL FUZZY FINDING -" buffers and files in current workdir -noremap s :lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy()) -" most recently used / MRU, bound to S since it is essentially a larger -" go-back intention than just buffers -noremap S :lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy()) -" fuzzy find files in cwd -noremap f :lua require 'telescope.builtin'.find_files({follow=true, hidden=true}) -" general full-text search in cwd with rg -noremap F :lua require 'telescope.builtin'.live_grep() - -" git status -noremap gs :lua require 'telescope.builtin'.git_status() -" git buffercommits -noremap gb :lua require 'telescope.builtin'.git_bcommits() -" git commitlog -noremap gl :lua require 'telescope.builtin'.git_commits() - -" helptags -noremap :lua require 'telescope.builtin'.help_tags() -" manpages -noremap :lua require 'telescope.builtin'.man_pages() - -" colorschemes -nnoremap :lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy()) - -" spell suggestions -nnoremap z= :lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy()) - -" Note Searching -" PLUGIN: Notational-FZF -" set notational-fzf-vim keys for the NV window itself -let g:nv_fzf_binds = [ - \ 'alt-a:select-all', - \ 'alt-q:deselect-all', - \ 'alt-p:toggle-preview', - \ 'alt-u:page-up', - \ 'alt-d:page-down', - \ 'ctrl-w:backward-kill-word', - \ ] -" FZF note full-text search with notational-velocity like functions (in wiki -" directory) -noremap n :NV -noremap N :NV! -" PLUGIN: CtrlSF -" (non-fuzzy) search in wiki with ctrlsf, in fullscreen window -nnoremap wF :execute(":call SearchNotes()") -" PLUGIN: wiki.vim -" use wiki.vim to look through document outlines in fzf (only for note -" directory atm) -" leader is used when it is callable from anywhere -" localleader is used when it is specific to the local file -nnoremap wf :WikiFzfPages -nnoremap wt :WikiFzfTags -" use default TOC shortcut for viewing wikitoc if in correct filetype -augroup wikitoc - autocmd! - autocmd Filetype markdown,pandoc nnoremap gO :WikiFzfToc -augroup END - -" overwrites some default mappings I don't use, or that interfere with my own -" mappings TODO: currently this just assigns bogus shortcuts, since the plugin grumbles -" when setting to an empty string -let g:wiki_mappings_local = { - \ '(wiki-link-next)' : '', - \ '(wiki-link-prev)' : '', - \ '(wiki-link-return)' : '', - \ 'v_(wiki-link-toggle-visual)' : '', - \ '(wiki-graph-find-backlinks)' : 'wb', - \ '(wiki-graph-in)' : 'wg', - \ '(wiki-graph-out)' : 'wG', - \} -" additional zettelkasten mapping -augroup zettelkasten - autocmd! - autocmd Filetype markdown,pandoc nnoremap :lua require 'zettelkasten'.open_or_make_link() - autocmd Filetype markdown,pandoc vnoremap :lua require 'zettelkasten'.open_or_make_link(true) -augroup END - -" Mostly dealing with Prose writing from here on out -" Format current Paragraph (esp useful in prose writing) -nnoremap q gqap -xnoremap q gq -nnoremap Q vapJgqap - -" PLUGIN: GOYO -" Enter distraction free prose mode with F11 -noremap :Goyo - -" PLUGIN: fzf-bibtex -" map @@ to automatically insert citation reference at cursor -inoremap @@ u:CiteRef -" map cc to insert a complete citation at cursor -nnoremap cc :CiteRef -" map cm to insert markdown prettified citation -nnoremap cm :CiteMarkdown - -" SPELL CHECKING -" Spell check set to O, 'o' for 'orthography': -" Move to the prev/next spelling error with [S ]S -" Move to the prev/next spelling error or suggestion with [s ]s -noremap Z :setlocal spell! spelllang=en_us -noremap ZE :setlocal spell! spelllang=en_us -noremap ZG :setlocal spell! spelllang=de_de -noremap zz 1z= - -" PLUGIN: tq thesaurus_query.vim -nnoremap zt :ThesaurusQueryReplaceCurrentWord -vnoremap zt "ky:ThesaurusQueryReplace k - -" pp to comPile a document (or file, works for some languages like go/python/c) -" o to open the resulting document (mostly for pdfs) -" po to comPile *and* open a doc -" and all the same in uppercase for verbose output -nnoremap dp :DocCompile -nnoremap dP :DocCompile! -nnoremap do :DocOpen -nnoremap dO :DocOpen! - -" PLUGIN: easy-align -" Start interactive EasyAlign in visual mode (e.g. vipga) -xmap ga (EasyAlign) -" Start interactive EasyAlign for a motion/text object (e.g. gaip) -nmap ga (EasyAlign) diff --git a/nvim/.config/nvim/lua/_lsp.lua b/nvim/.config/nvim/lua/_lsp.lua deleted file mode 100644 index 11070cc..0000000 --- a/nvim/.config/nvim/lua/_lsp.lua +++ /dev/null @@ -1,133 +0,0 @@ -local api = vim.api - -local saga = require 'lspsaga' -local lspcfg = require 'lspconfig' -local compe = require 'compe' - --- Enable the following language servers -local servers = { - 'bashls', - 'gopls', - 'texlab', - 'pyright', - 'rust_analyzer', - 'tsserver', - 'vimls', - -- sumneko_lua further down, needs more setup -} - -vim.o.completeopt = "menuone,noselect" --- completion sources, higher priority = closer to the top? -compe.setup({ - source = { - nvim_lsp = true, - nvim_treesitter = true, - buffer = true, - path = true, - calc = true, - nvim_lua = true, - emoji = true, - spell = { - priority = 0, - }, - -- vsnip = true, - }, -}) - -local on_attach = function(_, _) - -- Keybindings for LSPs - -- Note these are in on_attach so that they don't override bindings in a non-LSP setting - api.nvim_set_keymap("n", "gh", "lua require 'lspsaga.provider'.lsp_finder()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "gd", "lua require'lspsaga.provider'.preview_definition()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "gE", "lua require 'lspsaga.codeaction'.code_action()", - {noremap = true, silent = true}) - api.nvim_set_keymap("v", "gE", "'<,'>lua require 'lspsaga.codeaction'.range_code_action()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "K", "lua require('lspsaga.hover').render_hover_doc()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "gK", "lua require('lspsaga.signaturehelp').signature_help()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "gr", "lua require('lspsaga.rename').rename()", - {noremap = true, silent = true}) - - api.nvim_set_keymap("n", "ge", "lua require('lspsaga.diagnostic').show_line_diagnostics()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "]e", "lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "[e", "lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()", - {noremap = true, silent = true}) - - api.nvim_set_keymap("n", "C-f", "lua require('lspsaga.action').smart_scroll_with_saga(1)", - {noremap = true, silent = true}) - api.nvim_set_keymap("n", "C-b", "lua require('lspsaga.action').smart_scroll_with_saga(-1)", - {noremap = true, silent = true}) - - require("lspsaga").init_lsp_saga { - error_sign = 'X', - warn_sign = '⚠️', - hint_sign = '⚡', - infor_sign = 'ℹ️', - code_action_icon = '●', - finder_definition_icon = '📖 ', - finder_reference_icon = '🔖 ', - definition_preview_icon = '📖 ', - finder_action_keys = { - open = '', - split = 's', - vsplit = 'v', - quit = '', - scroll_down = '', - scroll_up = '' - }, - code_action_keys = { - quit = '', - exec = '' - }, - rename_action_keys = { - quit = '', - exec = '' - }, - } - print('LSP ready') -end - --- set up simple servers -for _, lsp in ipairs(servers) do - lspcfg[lsp].setup { on_attach = on_attach } -end - --- requires the lua-language-server package to be installed --- The arch package defaults to the following directory -local sumneko_root_path = "/usr/share/lua-language-server" -lspcfg.sumneko_lua.setup { - cmd = { "lua-language-server", "-E", sumneko_root_path .. "/main.lua"}; - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = vim.split(package.path, ';'), - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {'vim', 'before_each', 'after_each', 'describe', 'it', 'mock', 'stub'}, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = { - [vim.fn.expand('$VIMRUNTIME/lua')] = true, - [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, - ["/usr/share/lua/5.1/busted/"] = true, - }, - }, - }, - }, - on_attach = on_attach, -} - -saga.init_lsp_saga() - -api.nvim_set_keymap("i", "", "compe#complete()", {expr = true, silent = true}) diff --git a/nvim/.config/nvim/lua/_telescope.lua b/nvim/.config/nvim/lua/_telescope.lua deleted file mode 100644 index 0a495a9..0000000 --- a/nvim/.config/nvim/lua/_telescope.lua +++ /dev/null @@ -1,12 +0,0 @@ -require("telescope").setup { - defaults = { - file_sorter = require("telescope.sorters").get_fzy_sorter - }, - extensions = { - fzy_native = { - override_generic_sorter = false, - override_file_sorter = true - } - } -} -require("telescope").load_extension("fzy_native") diff --git a/nvim/.config/nvim/lua/_treesitter.lua b/nvim/.config/nvim/lua/_treesitter.lua deleted file mode 100644 index 055b36c..0000000 --- a/nvim/.config/nvim/lua/_treesitter.lua +++ /dev/null @@ -1,13 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- one of "all", "maintained" (parsers with maintainers), or a list of languages - ensure_installed = "maintained", - highlight = { enable = true }, - incremental_selection = { enable = true }, - textobjects = { enable = true }, - indent = { enable = true }, - - -- enable rainbow brackets, needs p00f/nvim-ts-rainbow - rainbow = { - enable = true - } -} diff --git a/nvim/.config/nvim/lua/base/look.lua b/nvim/.config/nvim/lua/base/look.lua deleted file mode 100644 index 1b7d675..0000000 --- a/nvim/.config/nvim/lua/base/look.lua +++ /dev/null @@ -1,19 +0,0 @@ -local set_hl = require("helpers.highlight") -local augroup = require("helpers.augroup") - -set_hl("Comment", { gui = "italic" }) - --- local function override_hl_colors() --- vim.api.nvim_exec( --- [[ --- hi LspDiagnosticsVirtualTextError guifg=blue gui=bold,italic,underline --- hi LspDiagnosticsVirtualTextWarning guifg=pink gui=bold,italic,underline --- hi LspDiagnosticsVirtualTextInformation guifg=yellow gui=bold,italic,underline --- hi LspDiagnosticsVirtualTextHint guifg=green gui=bold,italic,underline --- ]], false) --- end - - -augroup({ - { 'ColorScheme', 'lua require("base.look").override_hl_colors()' } -}, 'override_highlights') diff --git a/nvim/.config/nvim/lua/base/plugins.lua b/nvim/.config/nvim/lua/base/plugins.lua deleted file mode 100644 index 6979af8..0000000 --- a/nvim/.config/nvim/lua/base/plugins.lua +++ /dev/null @@ -1,92 +0,0 @@ -local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim" - -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) -end - -vim.api.nvim_exec( - [[ - augroup Packer - autocmd! - autocmd BufWritePost plugins.lua PackerCompile - augroup END -]], - false -) - -local use = require("packer").use -require("packer").startup( - function() - -- packer manages itself - use "wbthomason/packer.nvim" - - -- - -- vim plugs - -- essential - use 'christoomey/vim-tmux-navigator' -- allow seamless navigation between vim buffers and tmux splits - use 'jeffkreeftmeijer/vim-numbertoggle' -- toggles numbers to absolute for all buffers but the current which is relative - use 'justinmk/vim-sneak' -- jump between letters with improved fFtT quicksearch - use 'RRethy/vim-illuminate' -- highlight other occurences of the word under cursor - - -- files - use 'vifm/vifm.vim' - - -- editing - use 'tpope/vim-commentary' -- easily toggle comments for lines, paragraphs etc with gc - use 'tpope/vim-surround' -- lets you change surrounding things with cs (or ds to del, ys to add) - use 'tommcdo/vim-exchange' -- adds exchange operator with cx. common use: cxiw . on 2 words to switch - use 'jiangmiao/auto-pairs' -- Auto close brackets and '' - use 'junegunn/vim-easy-align' -- Align tables and other alignable things - use 'junegunn/vim-peekaboo' -- Show the contents of regiseters on pasting from '', @, - - -- fuzzy - use {"nvim-telescope/telescope.nvim", requires = {{"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"}}} - use "nvim-telescope/telescope-fzy-native.nvim" - - -- linting - use 'desmap/ale-sensible' - use 'w0rp/ale' -- asynchronous linting - might be superseded by lsp or coc.nvim at some point - - -- statusline - use 'vim-airline/vim-airline' - use 'vim-airline/vim-airline-themes' - use 'edkolev/tmuxline.vim' - - -- colorschemes - use 'chriskempson/base16-vim' - use 'reedes/vim-colors-pencil' - - -- writing - use 'vim-pandoc/vim-pandoc-syntax' - use 'vim-pandoc/vim-pandoc' - use 'micarmst/vim-spellsync' -- personal dict improvements for git sync - use 'ron89/thesaurus_query.vim' -- find thesaurus backed synonyms for word under cursor - use 'kana/vim-textobj-user' -- dependency for most other textobj plugins - use 'reedes/vim-textobj-sentence' -- extends the capabilities of sentence detection - use 'junegunn/goyo.vim' -- provide distraction free writing - use 'junegunn/limelight.vim' -- provide even distraction free-er writing (lowlight paragraphs) - use 'lervag/wiki.vim' -- foundational wiki system, allowing links between plaintext files - use 'dyng/ctrlsf.vim' -- search-and-edit of many wiki files at once - use 'alok/notational-fzf-vim' -- quickly search through the wiki - - -- languages - use 'euclidianAce/BetterLua.vim' -- better syntax highlighting for lua - - -- - -- nvim plugs - - use 'erietz/vim-terminator' -- interactive code sending and repl-ing from vim - use {"lukas-reineke/indent-blankline.nvim", branch = "lua"} -- show a vertical line for each indentation - - -- lsp - use 'neovim/nvim-lspconfig' -- some commong language server configurations - use 'glepnir/lspsaga.nvim' -- nice and fast ui for lsp actions - use 'hrsh7th/nvim-compe' -- simple completion engine built specifically for nvim and lsp - - -- treesitter - use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} - use 'p00f/nvim-ts-rainbow' -- rainbow brackets using treesitter - - use 'marty-oehme/zettelkasten.nvim' - end -) diff --git a/nvim/.config/nvim/lua/gitlens.lua b/nvim/.config/nvim/lua/gitlens.lua deleted file mode 100644 index 873bc71..0000000 --- a/nvim/.config/nvim/lua/gitlens.lua +++ /dev/null @@ -1,44 +0,0 @@ -local M = {} -local api = vim.api - -function M.blameVirtText() - - -- get the current file extension - local ft = vim.fn.expand('%:h:t') - - if ft == '' or ft == 'bin' then -- if we are in a scratch buffer, unknown filetype, or nvim's terminal window - return - end - - M.clearBlameVirtText() - - local currFile = vim.fn.expand('%') - local line = api.nvim_win_get_cursor(0) - local blame = vim.fn.system(string.format('git blame -c -L %d,%d %s', - line[1], line[1], currFile)) - local hash = vim.split(blame, '%s')[1] - local cmd = string.format("git show %s ", hash) .. - "--format='%an | %ar | %s'" - - if hash == '00000000' then - text = 'Not Committed Yet' - else - text = vim.fn.system(cmd) - text = vim.split(text, '\n')[1] - if text:find("fatal") then -- if the call to git show fails - text = 'Not Committed Yet' - end - end - - -- set virtual text for namespace 2 with the content from git and assign it to the higlight group 'GitLens' - api.nvim_buf_set_virtual_text(0, 2, line[1] - 1, {{text, 'GitLens'}}, {}) - -end - --- important for clearing out the text when our cursor moves -function M.clearBlameVirtText() - -- clear out virtual text from namespace 2 (the namespace we will set later) - api.nvim_buf_clear_namespace(0, 2, 0, -1) -end - -return M diff --git a/nvim/.config/nvim/lua/look.lua b/nvim/.config/nvim/lua/look.lua new file mode 100644 index 0000000..5ed11d2 --- /dev/null +++ b/nvim/.config/nvim/lua/look.lua @@ -0,0 +1,16 @@ +local b = require('base16') + +-- italic comments if supported +local set_hl = require("helpers.highlight") +set_hl("Comment", {gui = "italic"}) +vim.api.nvim_set_var('gruvbox_italic', 1) +vim.api.nvim_set_var('one_allow_italics', 1) +vim.api.nvim_set_var('pencil_terminal_italics', 1) + +function B16theme(theme) + local base16scheme = b.themes[theme] + b(base16scheme, true) +end + +-- set the default colorscheme +B16theme('eighties') diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua new file mode 100644 index 0000000..e4f4e3e --- /dev/null +++ b/nvim/.config/nvim/lua/maps.lua @@ -0,0 +1,263 @@ +local map = require 'cartographer' + +-- The general ideas behind these mappings: +-- +-- * Leader prefix is the generally preferred way to map new things, however +-- only for those that affect all of vim +-- +-- * Localleader prefix is used for mappings which only affect single buffers, +-- in other words mostly filetype specific mappings +-- +-- many of these mapping ideas come from Tom Ryder who has them nicely +-- documented + +-- backspace to switch to alternate (last) buffer +map.n.nore[''] = '' + +-- since u undoes, would it not make sense that U redoes? +map.n.nore['U'] = '' + +-- d-motion puts the last 'deleted' thing into the default register to paste; +-- use D-motion to truly delete something into nothingness and keep whatever +-- you want in your register, ready to paste +map.n.nore['D'] = '"_d' + +-- I don't particularly need ex mode (at least, yet) but faster macro access +-- is nice +map.n.nore['Q'] = '@' + +-- stronger versions of left,right - move all the way to beginning/end of line +map.n.nore['H'] = '^' +map.n.nore['L'] = '$' + +-- when in softwrapped files, allow moving through the visible lines with j/k +-- but when prepending a number jump *exactly* as many lines, wrapped or not +-- This makes relative linenumbers much more useful in prose docs since they +-- are always exactly correct +local function wrap_up() + if vim.v.count == 0 then return 'gk' end + return 'k' +end +local function wrap_down() + if vim.v.count == 0 then return 'gj' end + return 'j' +end +map.n.nore.expr['k'] = wrap_up +map.n.nore.expr['j'] = wrap_down + +-- move around between matching brackets with tab +map.n.nore[''] = '%' + +-- when in insertion mode, C-u uppercases the current word, C-l lowercases it, +map.i.nore[''] = 'gUiw`]a' +map.i.nore[''] = 'guiw`]a' + +-- let me save stuff as sudo when I forget to call vim with it +map.c.nore['w!!'] = + [[execute 'silent! write !sudo tee % >/dev/null' edit!]] + +-- yank filename to f buffer +map.n.nore['yf'] = ':let @f = expand("%")' + +-- repeat the last substitute command with all its flags preserved +map.n.nore['&'] = ':&&' + +-- bracket pairings to go to the next/previous of: +-- (works with count prefixes) +-- Argument list +map.n.nore['[a'] = ':previous' +map.n.nore[']a'] = ':next' +-- Buffers +map.n.nore['[b'] = ':bprevious' +map.n.nore[']b'] = ':bnext' +-- Quickfix list +map.n.nore['[c'] = ':cprevious' +map.n.nore[']c'] = ':cnext' +-- Location list +map.n.nore['[l'] = ':lprevious' +map.n.nore[']l'] = ':lnext' +-- Hunks (from gitsigns) +map.n.nore.expr['[h'] = + [[&diff ? ']c' : 'lua require("gitsigns.actions").prev_hunk()']] +map.n.nore.expr[']h'] = + [[&diff ? '[c' : 'lua require("gitsigns.actions").next_hunk()']] + +-- set our leader key to space since with hjkl, space is largely useless +vim.g.mapleader = " " + +-- maps the leader for buffer local mappings +-- since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does +-- not do too many useful things and can be taken up as localleader +vim.g.maplocalleader = "," + +-- If we mapped localleader to comma, we can still get to its original function +-- by douple-tapping it. +if vim.g.maplocalleader == ',' then + map.nore[',,'] = ',' + map.s[',,'] = nil +end + +-- remove search highlights by pressing space+/ +map.n.nore['/'] = ':noh' + +-- split buffers vertically/horizontally with the leader \ or - (mirrors my +-- tmux setup) +map.n.nore['-'] = ':sp' +map.n.nore['\\'] = ':vsp' +-- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) +map.n.nore['t'] = ':vsp .' +-- open actual new tab with leader-T +map.n.nore['T'] = ':tabedit .' + +-- select the whole buffer with -a +map.n.nore['a'] = 'ggVG' + +-- CONFIG EDITING +-- quickly edit vimrc with leader+V +map.n.nore['V'] = ':vsp $MYVIMRC' +-- source vimrc with keystroke combination +map.n.nore['VV'] = ':source $MYVIMRC' + +-- PLUGIN: Vifm.vim +-- open/close file tree with leader-e +map.n.nore['e'] = ':Vifm' +-- open current file tree with current file directory +map.n.nore['E'] = ':Vifm getcwd()' + +-- PLUGIN: Telescope GLOBAL FUZZY FINDING +-- buffers and files in current workdir +map.n.nore['s'] = + [[:lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())]] +-- most recently used / MRU, bound to S since it is essentially a larger +-- go-back intention than just buffers +map.n.nore['S'] = + [[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())]] +-- fuzzy find files in cwd +map.n.nore['f'] = + [[:lua require 'telescope.builtin'.find_files({follow=true, hidden=true})]] +-- general full-text search in cwd with rg +map.n.nore['F'] = + [[:lua require 'telescope'.extensions.fzf_writer.grep()]] + +-- git status +map.n.nore['gs'] = [[:lua require 'telescope.builtin'.git_status()]] +-- git buffercommits +map.n.nore['gb'] = + [[:lua require 'telescope.builtin'.git_bcommits()]] +-- git commitlog +map.n.nore['gl'] = + [[:lua require 'telescope.builtin'.git_commits()]] + +-- helptags +map.n.nore[''] = + [[:lua require 'telescope.builtin'.help_tags()]] +-- manpages +map.n.nore[''] = + [[:lua require 'telescope.builtin'.man_pages()]] + +-- colorschemes +map.n.nore[''] = + [[:lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())]] + +-- spell suggestions +map.n.nore['z='] = + [[:lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())]] + +-- Note Searching +-- PLUGIN: Notational-FZF +-- set notational-fzf-vim keys for the NV window itself +vim.g.nv_fzf_binds = { + 'alt-a:select-all', 'alt-q:deselect-all', 'alt-p:toggle-preview', + 'alt-u:page-up', 'alt-d:page-down', 'ctrl-w:backward-kill-word' +} +-- FZF note full-text search with notational-velocity like functions (in wiki +-- directory) +map.n.nore['n'] = ':NV' +map.n.nore['N'] = ':NV!' + +-- PLUGIN: CtrlSF +-- (non-fuzzy) search in wiki with ctrlsf, in fullscreen window +map.n.nore['wf'] = ':call SearchNotes()' + +-- Mostly dealing with Prose writing from here on out +-- Format current Paragraph (esp useful in prose writing) +map.n.nore.silent['q'] = 'gqap' +map.x.nore.silent['q'] = 'gq' +map.n.nore.silent['Q'] = 'vapJgqap' + +-- Enter distraction free prose mode with F11 +map.n.nore.silent[''] = ':TZAtaraxis' +map.n.nore.silent[''] = ':TZMinimalist' + +-- PLUGIN: fzf-bibtex +-- map @@ to automatically insert citation reference at cursor +map.i.nore.silent['@@'] = 'u:CiteRef' +-- map cc to insert a complete citation at cursor +map.n.nore.silent['cc'] = ':CiteRef' +-- map cm to insert markdown prettified citation +map.n.nore.silent['cm'] = ':CiteMarkdown' + +-- SPELL CHECKING +-- Spell check set to O, 'o' for 'orthography': +-- Move to the prev/next spelling error with [S ]S +-- Move to the prev/next spelling error or suggestion with [s ]s +map.n.nore['Z'] = ':setlocal spell! spelllang=en_us,de_de' +map.n.nore['ZE'] = ':setlocal spell! spelllang=en_us' +map.n.nore['ZG'] = ':setlocal spell! spelllang=en_us' +map.n.nore['zz'] = '1z=' + +-- PLUGIN: tq thesaurus_query.vim +-- nnoremap zt :ThesaurusQueryReplaceCurrentWord +map.n.nore['zt'] = ':ThesaurusQueryReplaceCurrentWord' +map.v.nore['zt'] = '"ky:ThesaurusQueryReplace k' + +-- pp to comPile a document (or file, works for some languages like go/python/c) +-- o to open the resulting document (mostly for pdfs) +-- po to comPile *and* open a doc +-- and all the same in uppercase for verbose output +map.n.nore['dp'] = ':DocCompile' +map.n.nore['dP'] = ':DocCompile!' +map.n.nore['do'] = ':DocOpen' +map.n.nore['dO'] = ':DocOpen!' + +-- PLUGIN: easy-align +-- Start interactive EasyAlign in visual mode (e.g. vipga) +map.x['ga'] = '(EasyAlign)' +-- Start interactive EasyAlign for a motion/text object (e.g. gaip) +map.n['ga'] = '(EasyAlign)' + +-- PLUGIN: Navigator.nvim +map.n.nore.silent[''] = "lua require('Navigator').left()" +map.n.nore.silent[''] = "lua require('Navigator').up()" +map.n.nore.silent[''] = "lua require('Navigator').right()" +map.n.nore.silent[''] = "lua require('Navigator').down()" +map.n.nore.silent[''] = "lua require('Navigator').previous()" + +-- PLUGIN: compe.nvim +-- lsp keymaps are set in lsp settings, only for lsp buffers +map.i.nore.expr.silent[''] = 'compe#complete()' +map.i.expr[''] = + [[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']] +map.i.expr[''] = + [[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']] + +-- PLUGIN: symbols-outline.nvim +map.n.nore.silent['o'] = "SymbolsOutline" + +-- PLUGIN: dial-increment +map.n[''] = '(dial-increment)' +map.n[''] = '(dial-decrement)' +map.v[''] = '(dial-increment)' +map.v[''] = '(dial-decrement)' +map.v['g'] = '(dial-increment-additional)' +map.v['g'] = '(dial-decrement-additional)' + +-- PLUGIN: zettelkasten.nvim +map.n.nore[''] = + [[:silent lua require 'zettelkasten'.open_or_make_link()]] +map.v.nore[''] = [[:lua require 'zettelkasten'.open_or_make_link(true)]] +map.n.nore['ww'] = [[:lua require 'zettelkasten'.open_index() ]] + +-- PLUGIN: toggleterm.nvim +-- create a lazygit window, set up in toggleterm settings +map.n.nore['G'] = ':Lazygit' diff --git a/nvim/.config/nvim/lua/pandoc_complete.lua b/nvim/.config/nvim/lua/personal/pandoc_complete.lua similarity index 100% rename from nvim/.config/nvim/lua/pandoc_complete.lua rename to nvim/.config/nvim/lua/personal/pandoc_complete.lua diff --git a/nvim/.config/nvim/lua/scratchpad.lua b/nvim/.config/nvim/lua/personal/scratchpad.lua similarity index 100% rename from nvim/.config/nvim/lua/scratchpad.lua rename to nvim/.config/nvim/lua/personal/scratchpad.lua diff --git a/nvim/.config/nvim/lua/plug/_autopair.lua b/nvim/.config/nvim/lua/plug/_autopair.lua new file mode 100644 index 0000000..6781edd --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_autopair.lua @@ -0,0 +1,16 @@ +require('nvim-autopairs').setup({check_ts = true}) +require("nvim-autopairs.completion.compe").setup({ + map_cr = true, -- map on insert mode + map_complete = true -- it will auto insert `(` after select function or method item +}) + +--- Auto-space rules +local npairs = require 'nvim-autopairs' +local Rule = require 'nvim-autopairs.rule' + +npairs.add_rules { + Rule(' ', ' '):with_pair(function(opts) + local pair = opts.line:sub(opts.col, opts.col + 1) + return vim.tbl_contains({'()', '[]', '{}'}, pair) + end) +} diff --git a/nvim/.config/nvim/lua/plug/_format.lua b/nvim/.config/nvim/lua/plug/_format.lua new file mode 100644 index 0000000..abc2630 --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_format.lua @@ -0,0 +1,70 @@ +local augroup = require('helpers.augroup') + +-- for each filetype autoformat on save +-- TODO can automatically gather from formatter table keys? +local filetypes = + 'bash,cpp,go,html,javascript,lua,python,rust,sh,typescript,zsh' +augroup({ + { + 'FileType', filetypes, 'autocmd', 'BufWritePost', '', + 'FormatWrite' + } +}, 'formatonsave') + +local prettierfmt = { + function() + return { + exe = "prettier", + args = { + "--stdin-filepath", vim.api.nvim_buf_get_name(0), + '--single-quote' + }, + stdin = true + } + end +} +local shfmt = { + function() return {exe = "shfmt", args = {"-i 4"}, stdin = true} end +} + +require('formatter').setup({ + logging = false, + filetype = { + bash = shfmt, + cpp = { + function() + return { + exe = "clang-format", + args = {}, + stdin = true, + cwd = vim.fn.expand('%:p:h') -- Run clang-format in cwd of the file. + } + end + }, + go = {function() return {exe = "goimports", stdin = true} end}, + html = prettierfmt, + javascript = prettierfmt, + lua = { + function() + return { + exe = "lua-format", + args = {"--indent-width", 4}, + stdin = true + } + end + }, + python = { + function() + return {exe = "black", args = {"-"}, stdin = true} + end + }, + rust = { + function() + return {exe = "rustfmt", args = {"--emit=stdout"}, stdin = true} + end + }, + sh = shfmt, + typescript = prettierfmt, + zsh = shfmt + } +}) diff --git a/nvim/.config/nvim/lua/plug/_galaxyline.lua b/nvim/.config/nvim/lua/plug/_galaxyline.lua new file mode 100644 index 0000000..7aeef64 --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_galaxyline.lua @@ -0,0 +1,244 @@ +-- set up statusline +local gl = require 'galaxyline' +local gls = gl.section +local fileinfo = require 'galaxyline.provider_fileinfo' +local devicons = require 'nvim-web-devicons' + +local mode_colors = { + normal = '#' .. '98c379', + insert = '#' .. '61afef', + replace = '#' .. 'e06c75', + visual = '#' .. 'e5c07b', + command = '#' .. 'd19a66', + terminal = '#' .. '56b6c2' +} + +-- create icons from unicode +local function u(code) + if type(code) == 'string' then code = tonumber('0x' .. code) end + local c = string.char + if code <= 0x7f then return c(code) end + local t = {} + if code <= 0x07ff then + t[1] = c(bit.bor(0xc0, bit.rshift(code, 6))) + t[2] = c(bit.bor(0x80, bit.band(code, 0x3f))) + elseif code <= 0xffff then + t[1] = c(bit.bor(0xe0, bit.rshift(code, 12))) + t[2] = c(bit.bor(0x80, bit.band(bit.rshift(code, 6), 0x3f))) + t[3] = c(bit.bor(0x80, bit.band(code, 0x3f))) + else + t[1] = c(bit.bor(0xf0, bit.rshift(code, 18))) + t[2] = c(bit.bor(0x80, bit.band(bit.rshift(code, 12), 0x3f))) + t[3] = c(bit.bor(0x80, bit.band(bit.rshift(code, 6), 0x3f))) + t[4] = c(bit.bor(0x80, bit.band(code, 0x3f))) + end + return table.concat(t) +end + +local mode_map = { + ['n'] = {'NORMAL', mode_colors.normal}, + ['i'] = {'INSERT', mode_colors.insert}, + ['R'] = {'REPLACE', mode_colors.replace}, + ['v'] = {'VISUAL', mode_colors.visual}, + ['V'] = {'V-LINE', mode_colors.visual}, + ['c'] = {'COMMAND', mode_colors.command}, + ['s'] = {'SELECT', mode_colors.visual}, + ['S'] = {'S-LINE', mode_colors.visual}, + ['t'] = {'TERMINAL', mode_colors.terminal}, + [''] = {'V-BLOCK', mode_colors.visual}, + [''] = {'S-BLOCK', mode_colors.visual}, + ['Rv'] = {'VIRTUAL'}, + ['rm'] = {'--MORE'} +} + +local sep = { + right_filled = u 'e0b2', + left_filled = u 'e0b0', + right = u 'e0b3', + left = u 'e0b1' +} + +local icons = { + locker = u 'f023', + unsaved = u 'f693', + lsp_warn = u 'f071', + lsp_error = u 'f46e' +} + +local function mode_label() return mode_map[vim.fn.mode()][1] or 'N/A' end +local function mode_hl() return mode_map[vim.fn.mode()][2] or '#ff0000' end + +local function highlight(group, fg, bg, gui) + local cmd = string.format('highlight %s guifg=%s guibg=%s', group, fg, bg) + if gui ~= nil then cmd = cmd .. ' gui=' .. gui end + vim.cmd(cmd) +end + +local function buffer_not_empty() + if vim.fn.empty(vim.fn.expand '%:t') ~= 1 then return true end + return false +end + +local function wide_enough() + local squeeze_width = vim.fn.winwidth(0) + if squeeze_width > 80 then return true end + return false +end + +gl.short_line_list = {'NvimTree', 'vista', 'dbui'} + +gls.left = { + { + ViMode = { + provider = function() + local modehl = mode_hl() + highlight('GalaxyViMode', '000000', modehl, 'bold') + highlight('GalaxyViModeInv', modehl, '000000', 'bold') + return string.format(' %s ', mode_label()) + end, + separator = sep.left_filled, + separator_highlight = 'GalaxyViModeInv' + } + }, { + FileName = { + provider = function() + if not buffer_not_empty() then return '' end + local fname + if wide_enough() then + fname = vim.fn.fnamemodify(vim.fn.expand '%', ':~:.') + else + fname = vim.fn.expand '%:t' + end + if #fname == 0 then return '' end + if vim.bo.readonly then + fname = fname .. ' ' .. icons.locker + end + if vim.bo.modified then + fname = fname .. ' ' .. icons.unsaved + end + return ' ' .. fname .. ' ' + end, + highlight = 'Normal', + separator = sep.left, + separator_highlight = 'GalaxyViModeInv' + } + }, { + -- I am unsure how lua specifies order in these, or are tables unordered? + -- anyway, without the weird section in between add ALWAYS appears to the left + -- of the Branch display + DiffAdd = { + provider = 'DiffAdd', + condition = wide_enough, + icon = '+', + highlight = 'DiffAdded' + }, + WithoutThisAddedComesBeforeBranch = { + provider = function() return '' end + }, + DiffModified = { + provider = 'DiffModified', + condition = wide_enough, + icon = '~', + highlight = 'DiffLine' + }, + DiffRemove = { + provider = 'DiffRemove', + condition = wide_enough, + icon = '-', + highlight = 'DiffRemoved', + separator = sep.left, + separator_highlight = 'GalaxyViModeInv' + }, + GitBranch = { + provider = { + function() return '  ' end, 'GitBranch', + function() return ' ' end + }, + condition = require('galaxyline.condition').check_git_workspace and + wide_enough, + highlight = 'NonText' + } + } +} + +gls.right = { + { + LspStatus = { + provider = function() + local connected = + not vim.tbl_isempty(vim.lsp.buf_get_clients(0)) + if connected then + return ' ' .. u 'f817' .. ' ' + else + return '' + end + end, + highlight = 'DiffAdded', + separator = sep.right, + separator_highlight = 'GalaxyViModeInv' + } + }, { + DiagnosticWarn = { + provider = function() + local n = vim.lsp.diagnostic.get_count(0, 'Warning') + if n == 0 then return '' end + return string.format(' %s %d ', icons.lsp_warn, n) + end, + highlight = 'LspDiagnosticsDefaultWarning' + }, + DiagnosticError = { + provider = function() + local n = vim.lsp.diagnostic.get_count(0, 'Error') + if n == 0 then return '' end + return string.format(' %s %d ', icons.lsp_error, n) + end, + highlight = 'LspDiagnosticsDefaultError' + } + }, { + FileIcon = { + provider = function() + local fname, ext = vim.fn.expand '%:t', vim.fn.expand '%:e' + local icon, _ = devicons.get_icon(fname, ext) + if icon == nil then return '' end + return ' ' .. icon .. ' ' + end, + separator = sep.right, + highlight = 'Normal', + separator_highlight = 'GalaxyViModeInv' + }, + FileType = { + provider = function() + -- if not buffer_not_empty() then + -- return '' + -- end + return string.format(' %s ', vim.bo.filetype) + end, + -- condition = buffer_not_empty, + highlight = 'Normal' + } + }, { + PositionInfo = { + provider = { + function() + return string.format('%s:%s', vim.fn.line('.'), + vim.fn.col('.')) + end + }, + highlight = 'GalaxyViMode', + separator = sep.right_filled, + separator_highlight = 'GalaxyViModeInv' + }, + PercentInfo = { + provider = fileinfo.current_line_percent, + highlight = 'GalaxyViMode', + separator = sep.right, + separator_highlight = 'GalaxyViMode' + } + } +} +for k, v in pairs(gls.left) do gls.short_line_left[k] = v end +table.remove(gls.short_line_left, 1) + +for k, v in pairs(gls.right) do gls.short_line_right[k] = v end +table.remove(gls.short_line_right) +table.remove(gls.short_line_right) diff --git a/nvim/.config/nvim/lua/_indentation.lua b/nvim/.config/nvim/lua/plug/_indent-blankline.lua similarity index 85% rename from nvim/.config/nvim/lua/_indentation.lua rename to nvim/.config/nvim/lua/plug/_indent-blankline.lua index 75a08ce..3aebee3 100644 --- a/nvim/.config/nvim/lua/_indentation.lua +++ b/nvim/.config/nvim/lua/plug/_indent-blankline.lua @@ -1,14 +1,14 @@ -- Settings for indentBlankline -- turn off for diff views since we want to compare directly if vim.wo.diff then - vim.g["indent_blakline_enabled"] = false + vim.g["indent_blankline_enabled"] = false end vim.g.indent_blankline_char = "▏" vim.g.indent_blankline_filetype_exclude = { "help", "undotree", - "markdown", "text", "pandoc", + "markdown", "text", "pandoc", "rst", "asciidoc", "vim-plug" } vim.g.indent_blankline_buftype_exclude = {"terminal"} diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua new file mode 100644 index 0000000..36bcee2 --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -0,0 +1,147 @@ +local api = vim.api + +local saga = require 'lspsaga' +local lspcfg = require 'lspconfig' +local compe = require 'compe' + +-- Enable the following language servers +local servers = { + 'bashls', 'gopls', 'texlab', 'pyright', 'rust_analyzer', 'tsserver', 'vimls' + -- sumneko_lua further down, needs more setup +} + +vim.o.completeopt = "menuone,noselect" +-- completion sources, higher priority = closer to the top? +compe.setup({ + source = { + nvim_lsp = {kind = ""}, + nvim_treesitter = {kind = "⧻"}, + buffer = {kind = ""}, + path = {kind = ""}, + calc = {kind = ""}, + nvim_lua = true, + emoji = { + kind = "ﲃ", + filetypes = {"markdown", "text", "pandoc", "rst", "asciidoc"} + }, + latex_symbols = { + kind = "λ", + filetypes = {"markdown", "text", "pandoc", "rst", "asciidoc"} + }, + tmux = {kind = "τ"}, + spell = {kind = "", priority = 0}, + vsnip = true + } +}) + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true +capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = {'documentation', 'detail', 'additionalTextEdits'} +} + +local on_attach = function(_, _) + -- Keybindings for LSPs + -- Note these are in on_attach so that they don't override bindings in a non-LSP setting + api.nvim_set_keymap("n", "gh", + "lua require 'lspsaga.provider'.lsp_finder()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "gd", + "lua require'lspsaga.provider'.preview_definition()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "gE", + "lua require 'lspsaga.codeaction'.code_action()", + {noremap = true, silent = true}) + api.nvim_set_keymap("v", "gE", + "'<,'>lua require 'lspsaga.codeaction'.range_code_action()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "K", + "lua require('lspsaga.hover').render_hover_doc()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "gK", + "lua require('lspsaga.signaturehelp').signature_help()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "gr", + "lua require('lspsaga.rename').rename()", + {noremap = true, silent = true}) + + api.nvim_set_keymap("n", "ge", + "lua require('lspsaga.diagnostic').show_line_diagnostics()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "]e", + "lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "[e", + "lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()", + {noremap = true, silent = true}) + + api.nvim_set_keymap("n", "C-f", + "lua require('lspsaga.action').smart_scroll_with_saga(1)", + {noremap = true, silent = true}) + api.nvim_set_keymap("n", "C-b", + "lua require('lspsaga.action').smart_scroll_with_saga(-1)", + {noremap = true, silent = true}) + + require("lspsaga").init_lsp_saga { + error_sign = 'X', + warn_sign = '⚠️', + hint_sign = '⚡', + infor_sign = 'ℹ️', + code_action_icon = '●', + finder_definition_icon = '📖 ', + finder_reference_icon = '🔖 ', + definition_preview_icon = '📖 ', + finder_action_keys = { + open = '', + split = 's', + vsplit = 'v', + quit = '', + scroll_down = '', + scroll_up = '' + }, + code_action_keys = {quit = '', exec = ''}, + rename_action_keys = {quit = '', exec = ''} + } + vim.cmd("command! LspHover lua vim.lsp.buf.hover()") + vim.cmd( + "command! LspDisable lua vim.lsp.stop_client(vim.lsp.get_active_clients())") + print('LSP ready') +end + +-- set up simple servers +for _, lsp in ipairs(servers) do lspcfg[lsp].setup {on_attach = on_attach} end + +-- requires the lua-language-server package to be installed +-- The arch package defaults to the following directory +local sumneko_root_path = "/usr/share/lua-language-server" +lspcfg.sumneko_lua.setup { + cmd = {"lua-language-server", "-E", sumneko_root_path .. "/main.lua"}, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = vim.split(package.path, ';') + }, + diagnostics = { + -- Get the language server to recognize additional globals + globals = { + 'vim', 'before_each', 'after_each', 'describe', 'it', + 'mock', 'stub' + } + }, + workspace = { + -- Make the server aware of additional runtime files + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + ["/usr/share/lua/5.1/busted/"] = true + } + } + } + }, + on_attach = on_attach +} + +saga.init_lsp_saga() diff --git a/nvim/.config/nvim/lua/plug/_telescope.lua b/nvim/.config/nvim/lua/plug/_telescope.lua new file mode 100644 index 0000000..4b5e4ed --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_telescope.lua @@ -0,0 +1,32 @@ +require("telescope").setup { + defaults = { + file_sorter = require("telescope.sorters").get_fzy_sorter, + vimgrep_arguments = { + 'rg', + '--ignore-vcs', + '--hidden', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case' + }, + }, + extensions = { + fzy_native = { + override_generic_sorter = false, + override_file_sorter = true + }, + fzf_writer = { + minimum_grep_characters = 2, + minimum_files_characters = 2, + + -- Disabled by default. + -- Will probably slow down some aspects of the sorter, but can make color highlights. + use_highlighter = true, + } + } +} +require("telescope").load_extension("fzy_native") +require("telescope").load_extension("fzf_writer") diff --git a/nvim/.config/nvim/lua/plug/_toggleterm.lua b/nvim/.config/nvim/lua/plug/_toggleterm.lua new file mode 100644 index 0000000..0940b82 --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_toggleterm.lua @@ -0,0 +1,18 @@ +require("toggleterm").setup { + open_mapping = [[=]], + insert_mappings = false -- don't map the key in insert mode +} + +local Terminal = require('toggleterm.terminal').Terminal +-- create a lazygit window with the lazygit command +local lazygit = Terminal:new({ + cmd = "lazygit", + hidden = true, + direction = 'float', + float_opts = {border = "curved"} +}) +function _Lazygit_toggle() lazygit:toggle() end +vim.cmd([[command! Lazygit :lua _Lazygit_toggle()]]) + +-- vim.api.nvim_set_keymap("n", "g", "lua _lazygit_toggle()", +-- {noremap = true, silent = true}) diff --git a/nvim/.config/nvim/lua/plug/_treesitter.lua b/nvim/.config/nvim/lua/plug/_treesitter.lua new file mode 100644 index 0000000..64b0513 --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_treesitter.lua @@ -0,0 +1,14 @@ +require'nvim-treesitter.configs'.setup { + -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ensure_installed = "maintained", + highlight = {enable = true}, + incremental_selection = {enable = true}, + textobjects = {enable = true}, + indent = {enable = true}, + + -- enable rainbow brackets, needs p00f/nvim-ts-rainbow + rainbow = {enable = true}, + + -- for improved commentstrings, needs corresponding plugin + context_commentstring = {enable = true} +} diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..96a50eb --- /dev/null +++ b/nvim/.config/nvim/lua/plugins.lua @@ -0,0 +1,173 @@ +local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim" + +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. + install_path) +end + +vim.api.nvim_exec([[ + augroup Packer + autocmd! + autocmd BufWritePost plugins.lua PackerCompile + augroup END +]], false) + +local use = require("packer").use +require("packer").startup(function() + -- packer manages itself + use "wbthomason/packer.nvim" + + -- vim plugs + -- essential + use { + 'numToStr/Navigator.nvim', + config = function() require('Navigator').setup() end + } -- allow seamless navigation between vim buffers and tmux splits + use 'jeffkreeftmeijer/vim-numbertoggle' -- toggles numbers to absolute for all buffers but the current which is relative + use 'RRethy/vim-illuminate' -- highlight other occurences of the word under cursor + use 'ggandor/lightspeed.nvim' -- jump between letters with improved fFtT quicksearch, mimics sneak + use 'lukas-reineke/indent-blankline.nvim' -- show a vertical line for each indentation + require('plug._indent-blankline') + + -- files + use 'vifm/vifm.vim' -- integrate file manager + use { + 'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter + requires = {'nvim-lua/plenary.nvim'}, + config = function() require('gitsigns').setup() end, + event = "BufRead" + } + use { + 'norcalli/nvim-colorizer.lua', -- color hex, named colors in the correct preview scheme + config = function() require('colorizer').setup() end + } + use { + 'mhartington/formatter.nvim', -- auto formatting on save + config = function() require('plug._format') end + } + + -- editing + use {'tpope/vim-commentary', event = "BufRead"} -- easily toggle comments for lines, paragraphs etc with gc + use { + 'blackCauldron7/surround.nvim', -- lets you change surrounding things with cs (or ds to del, ys to add) + config = function() + vim.g.surround_mappings_style = "surround" + vim.g.surround_pairs = { + nestable = {{'(', ')'}, {'[', ']'}, {'{', '}'}}, + linear = {{"'", "'"}, {'"', '"'}, {'*', '*'}, {'`', '`'}} + } + require('surround').setup {} + end + } + use 'monaqa/dial.nvim' -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers + use 'tommcdo/vim-exchange' -- adds exchange operator with cx. common use: cxiw . on 2 words to switch + use { + 'windwp/nvim-autopairs', + config = function() require('plug._autopair') end + } -- Auto close brackets and '' + use 'junegunn/vim-easy-align' -- Align tables and other alignable things + use "tversteeg/registers.nvim" -- Show the contents of regiseters on pasting from '', @, + use { -- highlight where the cursor jumps to + 'edluffy/specs.nvim', + config = function() require('specs').setup {} end + } + + -- linting + -- use 'desmap/ale-sensible' + -- use 'w0rp/ale' -- asynchronous linting - might be superseded by lsp or coc.nvim at some point + + -- colorschemes + use 'norcalli/nvim-base16.lua' + + -- statusline + use { + 'glepnir/galaxyline.nvim', + requires = {'kyazdani42/nvim-web-devicons', opt = true}, + config = function() require('plug._galaxyline') end + } + + -- writing + use 'vim-pandoc/vim-pandoc-syntax' + use 'vim-pandoc/vim-pandoc' + use 'micarmst/vim-spellsync' -- personal dict improvements for git sync + use 'ron89/thesaurus_query.vim' -- find thesaurus backed synonyms for word under cursor + use { -- provide distraction free writing + 'Pocco81/TrueZen.nvim', + config = function() + require("true-zen").setup({ + integrations = { + gitsigns = true, + galaxyline = true, + tmux = {global = false}, + limelight = true + } + }) + end + } + use 'junegunn/limelight.vim' -- provide even distraction free-er writing (lowlight paragraphs) + use 'dyng/ctrlsf.vim' -- search-and-edit of many wiki files at once + use 'alok/notational-fzf-vim' -- quickly search through the wiki + + -- languages + use 'euclidianAce/BetterLua.vim' -- better syntax highlighting for lua + + -- + -- nvim plugs + + use 'Iron-E/nvim-cartographer' -- makes it easier to set mappings through lua + use 'marty-oehme/zettelkasten.nvim' -- simple static markdown linking + use { + "akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim + event = "BufWinEnter", + config = function() require('plug._toggleterm') end + } + + -- fuzzy matching + use { + "nvim-telescope/telescope.nvim", + requires = {{"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"}}, + config = function() require('plug._telescope') end + } + use "nvim-telescope/telescope-fzy-native.nvim" + use "nvim-telescope/telescope-fzf-writer.nvim" + + -- lsp + use 'neovim/nvim-lspconfig' -- some commong language server configurations + use 'glepnir/lspsaga.nvim' -- nice and fast ui for lsp actions + use 'simrat39/symbols-outline.nvim' -- vista-like outline view for code + -- and completion + use 'hrsh7th/nvim-compe' -- simple completion engine built specifically for nvim and lsp + use 'GoldsteinE/compe-latex-symbols' -- adding unicode symbols for latex (/pandoc) files + use 'andersevenrud/compe-tmux' -- completion source from adjacent tmux panes + -- snippeting + use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine + use {"rafamadriz/friendly-snippets", event = "InsertEnter"} -- many snippets + + require('plug._lsp') + + -- treesitter + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + config = function() require('plug._treesitter') end + } + use 'nvim-treesitter/playground' -- interactively view and query the treesitter tree + use 'romgrk/nvim-treesitter-context' -- show current cursor context at top of buffer + use { + 'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches + config = function() + require'nvim-treesitter.configs'.setup { + textsubjects = { + enable = true, + keymaps = { + ['.'] = 'textsubjects-smart', + [';'] = 'textsubjects-container-outer' + } + } + } + end + } + use 'p00f/nvim-ts-rainbow' -- rainbow brackets using treesitter + use 'JoosepAlviste/nvim-ts-context-commentstring' -- improves commenting plugin above by using ts + +end) diff --git a/nvim/.config/nvim/lua/base/settings.lua b/nvim/.config/nvim/lua/settings.lua similarity index 87% rename from nvim/.config/nvim/lua/base/settings.lua rename to nvim/.config/nvim/lua/settings.lua index c695c8c..253f4c0 100644 --- a/nvim/.config/nvim/lua/base/settings.lua +++ b/nvim/.config/nvim/lua/settings.lua @@ -1,10 +1,19 @@ require("helpers.vimoptions") +local default_builtins_disabled = { + "netrw", + "netrwPlugin" +} +local disable_builtins = function(builtins) + for _, plugin in pairs(builtins) do + vim.g["loaded_" .. plugin] = 1 + end +end local apply_options = function(opts) - for k, v in pairs(opts) do - vim.opt[k] = v - end + for k, v in pairs(opts) do + vim.opt[k] = v + end end local o = { @@ -70,3 +79,4 @@ local o = { vim.api.nvim_set_var('tex_flavor', 'latex') apply_options(o) +disable_builtins(default_builtins_disabled) diff --git a/nvim/.config/nvim/plugin/airline.vim b/nvim/.config/nvim/plugin/airline.vim deleted file mode 100644 index 549645a..0000000 --- a/nvim/.config/nvim/plugin/airline.vim +++ /dev/null @@ -1,7 +0,0 @@ -" Design -" PLUGIN: AIRLINE -let g:airline_powerline_fonts=1 -" disable automatically refreshing the mux statusbar since it breaks tmux -" prefix highlighting. Instead, when changing vim statusbar just create -" snapshot with :TmuxlineSnapshot file and stick it into tmux config manually -let g:airline#extensions#tmuxline#enabled = 1 diff --git a/nvim/.config/nvim/plugin/ale.vim b/nvim/.config/nvim/plugin/ale.vim deleted file mode 100644 index 819f94f..0000000 --- a/nvim/.config/nvim/plugin/ale.vim +++ /dev/null @@ -1,31 +0,0 @@ - " PLUGIN: ALE -:scriptencoding utf-8 -" clearer Error and warning signs for the gutter -let g:ale_sign_error = '' -let g:ale_sign_warning = '' - -let g:ale_fix_on_save = 1 -let g:ale_fixers = { - \ 'javascript': ['prettier'], - \ 'html': ['prettier'], - \ 'typescript': ['prettier','tslint'], - \ '*': ['remove_trailing_lines', 'trim_whitespace'], - \ 'go': ['gofmt'], - \ 'sh': ['shfmt'], - \ 'zsh': ['shfmt'], - \ 'python': ['black', 'isort'], - \} -let g:ale_linters = { - \ 'go': ['gopls'], - \ 'sh': ['language_server','shellcheck'], - \ 'zsh': ['language_server','shellcheck'], - \ 'html': ['prettier'], - \ 'python': ['pylint'], - \} - -let g:ale_javascript_prettier_use_local_config = 1 - -" Enable integration with airline. -if exists('g:airline_theme') - let g:airline#extensions#ale#enabled = 1 -endif diff --git a/nvim/.config/nvim/plugin/colorschemes-font.vim b/nvim/.config/nvim/plugin/colorschemes-font.vim deleted file mode 100644 index b482874..0000000 --- a/nvim/.config/nvim/plugin/colorschemes-font.vim +++ /dev/null @@ -1,4 +0,0 @@ -" Enable italics for colorschemes that support them -let g:gruvbox_italic=1 -let g:one_allow_italics=1 -let g:pencil_terminal_italics=1 diff --git a/nvim/.config/nvim/plugin/fzf.vim b/nvim/.config/nvim/plugin/fzf.vim deleted file mode 100644 index e89fcd0..0000000 --- a/nvim/.config/nvim/plugin/fzf.vim +++ /dev/null @@ -1,49 +0,0 @@ -" PLUGIN: fzf.vim -" set some fzf defaults -" any Fzf command is prefixed with Fzf -" this groups them nicely together, and avoids confusion when suddenly :Buffer -" or :Files would appear as a command otherwise -let g:fzf_command_prefix = 'Fzf' -" let the colors come from our colorscheme -let g:fzf_colors = -\ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'gutter': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'Normal', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } - -let g:fzf_action = { - \ 'ctrl-t': 'tab split', - \ 'ctrl-s': 'split', - \ 'ctrl-v': 'vsplit' } - -" FzfRg but also search through hidden files -command! -bang -nargs=* FzfRgHidden - \ call fzf#vim#grep( - \ "rg --column --line-number --no-heading --color=always --smart-case --hidden --glob '!.git' ".shellescape(), 1, - \ fzf#vim#with_preview(), 0) - -" make fzf use the nvim floating window globally. (weee, technology!) -" -let $FZF_DEFAULT_OPTS="--layout=reverse --ansi" -let $FZF_DEFAULT_COMMAND="fd --type f --hidden --color=always -E '.git/'" -" to use fzf in a floating window only conditionally, the best approach would -" every command we want to floatize -if has('nvim-0.4.0') || has("patch-8.2.0191") - let g:fzf_layout = { 'window': { - \ 'width': 0.7, - \ 'height': 0.7, - \ 'highlight': 'PreProc', - \ 'border': 'rounded' } } -else " Fallback to a split window - let g:fzf_layout = { "window": "silent botright 16split enew" } -endif diff --git a/nvim/.config/nvim/plugin/goyo.vim b/nvim/.config/nvim/plugin/goyo.vim deleted file mode 100644 index d8ac0ac..0000000 --- a/nvim/.config/nvim/plugin/goyo.vim +++ /dev/null @@ -1,21 +0,0 @@ -" PLUGIN: goyo.vim -" set up functions for entering/exiting distraction free mode, or leaving it -function! s:goyo_enter() - " remove the tmux status bar for actual distraction free environment - silent !tmux set status off - " maximize the tmux pane that vim is in if any (usually I have vim open as the only pane) - silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z - " disable line highlighting, we really don't need it for prose - set nocursorline - " enable limelight which highlights whatever paragraph you are in and lowlights the rest - Limelight -endfunction -function! s:goyo_leave() - silent !tmux set status on - silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z - set cursorline - Limelight! -endfunction -" actually call the functions on entering/leaving goyo -autocmd! User GoyoEnter nested call goyo_enter() -autocmd! User GoyoLeave nested call goyo_leave() diff --git a/nvim/.config/nvim/plugin/notational-fzf-vim.vim b/nvim/.config/nvim/plugin/notational-fzf.vim similarity index 100% rename from nvim/.config/nvim/plugin/notational-fzf-vim.vim rename to nvim/.config/nvim/plugin/notational-fzf.vim diff --git a/nvim/.config/nvim/plugin/nvim-lspconfig.vim b/nvim/.config/nvim/plugin/nvim-lspconfig.vim deleted file mode 100644 index 4ec5d2a..0000000 --- a/nvim/.config/nvim/plugin/nvim-lspconfig.vim +++ /dev/null @@ -1,5 +0,0 @@ -command! LspHover lua vim.lsp.buf.hover() -command! LspDisable lua vim.lsp.stop_client(vim.lsp.get_active_clients()) - -" actual LSP config takes place in lua ('lua/lsp') -setlocal omnifunc=v:lua.vim.lsp.omnifunc diff --git a/nvim/.config/nvim/plugin/personal/gitlens.vim b/nvim/.config/nvim/plugin/personal/gitlens.vim deleted file mode 100644 index 250d158..0000000 --- a/nvim/.config/nvim/plugin/personal/gitlens.vim +++ /dev/null @@ -1,23 +0,0 @@ -function s:setupGitLens() - " -- disable gitlens unconditionally, and remove virtual text - lua require('gitlens').clearBlameVirtText() - augroup GitLens - autocmd! - augroup END - - " -- if it is wanted enable gitlens on holding the cursor - if g:gitlens_enable - augroup GitLens - autocmd! CursorHold * lua require('gitlens').blameVirtText() - autocmd! CursorMoved * lua require('gitlens').clearBlameVirtText() - autocmd! CursorMovedI * lua require('gitlens').clearBlameVirtText() - augroup END - endif -endfunction - -function s:toggleGitLens() - let g:gitlens_enable = !get(g:, 'gitlens_enable', 1) - call s:setupGitLens() -endfunction - -command! GitLensToggle call s:toggleGitLens() diff --git a/nvim/.config/nvim/plugin/personal/highlightyank.vim b/nvim/.config/nvim/plugin/personal/highlightyank.vim deleted file mode 100644 index f934dc9..0000000 --- a/nvim/.config/nvim/plugin/personal/highlightyank.vim +++ /dev/null @@ -1,5 +0,0 @@ -" will highlight any text which has been yanked -augroup LuaHighlightYank - autocmd! - autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank{timeout=500} -augroup END diff --git a/nvim/.config/nvim/plugin/personal/makescratch.vim b/nvim/.config/nvim/plugin/personal/makescratch.vim index 99cb3ce..600b406 100644 --- a/nvim/.config/nvim/plugin/personal/makescratch.vim +++ b/nvim/.config/nvim/plugin/personal/makescratch.vim @@ -12,4 +12,4 @@ " variable to the intended filetype. " ]]-- -command! -nargs=? -bang ScratchPad :lua require("scratchpad").create("","") +command! -nargs=? -bang ScratchPad :lua require("personal.scratchpad").create("","") diff --git a/nvim/.config/nvim/plugin/personal/showmappings.vim b/nvim/.config/nvim/plugin/personal/showmappings.vim deleted file mode 100644 index 09e5d33..0000000 --- a/nvim/.config/nvim/plugin/personal/showmappings.vim +++ /dev/null @@ -1,19 +0,0 @@ -" Show all mapped keys in a list - from https://stackoverflow.com/questions/13990136/display-a-ordered-vim-keyboard-mapping -function! s:ShowMaps() - let old_reg = getreg("a") " save the current content of register a - let old_reg_type = getregtype("a") " save the type of the register as well -try - redir @a " redirect output to register a - " Get the list of all key mappings silently, satisfy "Press ENTER to continue" - silent map | call feedkeys("\") - redir END " end output redirection - vnew " new buffer in vertical window - put a " put content of register - " Sort on 4th character column which is the key(s) - %!sort -k1.4,1.4 -finally " Execute even if exception is raised - call setreg("a", old_reg, old_reg_type) " restore register a -endtry -endfunction -" use :ShowMaps to call the function -command! ShowMappings call s:ShowMaps() " Enable :ShowMaps to call the function diff --git a/nvim/.config/nvim/plugin/personal/spellsuggest.vim b/nvim/.config/nvim/plugin/personal/spellsuggest.vim deleted file mode 100644 index da90be0..0000000 --- a/nvim/.config/nvim/plugin/personal/spellsuggest.vim +++ /dev/null @@ -1,13 +0,0 @@ -function! s:fzfSpellSink(word) - exe 'normal! "_ciw'.a:word -endfunction -function! FzfSpell() - let l:spellstatus = &spell - setlocal spell - let suggestions = spellsuggest(expand("")) - if l:spellstatus - return fzf#run({'source': suggestions, 'sink': function("s:fzfSpellSink"), 'right': "20%" }) - -endfunction - -command FzfSpellSuggest :call FzfSpell() diff --git a/nvim/.config/nvim/plugin/tmuxline.vim b/nvim/.config/nvim/plugin/tmuxline.vim deleted file mode 100644 index 30198e6..0000000 --- a/nvim/.config/nvim/plugin/tmuxline.vim +++ /dev/null @@ -1,10 +0,0 @@ -" custom preset with left-justified window list -" PLUGIN: TMUXLINE -let g:tmuxline_preset = { - \'a' : '#S', - \'b' : '#I:#P', - \'win' : '#I #W', - \'cwin' : [' ', '#I #W'], - \'y' : '#{?client_prefix,#[fg=colour232]#[bg=brightblue],} #(whoami)', - \'z' : '#H', - \'options' : {}} diff --git a/nvim/.config/nvim/plugin/vim-go.vim b/nvim/.config/nvim/plugin/vim-go.vim deleted file mode 100644 index 69ae5e1..0000000 --- a/nvim/.config/nvim/plugin/vim-go.vim +++ /dev/null @@ -1,25 +0,0 @@ -" PLUGIN: vim-go -" change the tabstops for go to use tabs and a width of 4 -" this conforms with the gofmt expectations -au FileType go set noexpandtab -au FileType go set shiftwidth=4 -au FileType go set softtabstop=4 -au FileType go set tabstop=4 -" enable all sorts of highlighting options for -" variables/functions/arguments... -let g:go_highlight_build_constraints = 1 -let g:go_highlight_extra_types = 1 -let g:go_highlight_fields = 1 -let g:go_highlight_functions = 1 -let g:go_highlight_methods = 1 -let g:go_highlight_operators = 1 -let g:go_highlight_structs = 1 -let g:go_highlight_types = 1 -" enable highlighting of other uses of the same variable -let g:go_auto_sameids = 0 -" automatically import needed dependencies -let g:go_fmt_command = "goimports" -" show type information for variables in the status line -let g:go_auto_type_info = 1 -" disable go info in status window, since it overlaps ALE linter information -let g:go_echo_go_info = 0 diff --git a/nvim/.config/nvim/plugin/vim-pandoc-syntax.vim b/nvim/.config/nvim/plugin/vim-pandoc-syntax.vim deleted file mode 100644 index cd38201..0000000 --- a/nvim/.config/nvim/plugin/vim-pandoc-syntax.vim +++ /dev/null @@ -1,3 +0,0 @@ -" PLUGIN: vim-pandoc-syntax -let g:pandoc#syntax#conceal#use = 1 -let g:pandoc#syntax#conceal#urls = 1 diff --git a/nvim/.config/nvim/plugin/vim-pandoc.vim b/nvim/.config/nvim/plugin/vim-pandoc.vim index faf946e..d662324 100644 --- a/nvim/.config/nvim/plugin/vim-pandoc.vim +++ b/nvim/.config/nvim/plugin/vim-pandoc.vim @@ -28,3 +28,7 @@ let g:pandoc#folding#fastfolds=1 let g:pandoc#spell#default_langs=["en_us", "de_de"] let g:pandoc#hypertext#ausosave_on_edit_open_link=1 let g:pandoc#hypertext#create_if_no_alternates_exists=1 + +" PLUGIN: vim-pandoc-syntax +let g:pandoc#syntax#conceal#use = 1 +let g:pandoc#syntax#conceal#urls = 1 diff --git a/nvim/.config/nvim/plugin/vim-peekaboo.vim b/nvim/.config/nvim/plugin/vim-peekaboo.vim deleted file mode 100644 index 7f1d400..0000000 --- a/nvim/.config/nvim/plugin/vim-peekaboo.vim +++ /dev/null @@ -1,31 +0,0 @@ -" PLUGIN: vim-peekaboo -let g:peekaboo_delay=500 - -function! CreateCenteredFloatingWindow() - let width = float2nr(&columns * 0.6) - let height = float2nr(&lines * 0.6) - let top = ((&lines - height) / 2) - 1 - let left = (&columns - width) / 2 - let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'} - - let top = "╭" . repeat("─", width - 2) . "╮" - let mid = "│" . repeat(" ", width - 2) . "│" - let bot = "╰" . repeat("─", width - 2) . "╯" - let lines = [top] + repeat([mid], height - 2) + [bot] - let s:buf = nvim_create_buf(v:false, v:true) - call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines) - call nvim_open_win(s:buf, v:true, opts) - set winhl=Normal:Floating - let opts.row += 1 - let opts.height -= 2 - let opts.col += 2 - let opts.width -= 4 - call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts) - au BufWipeout exe 'bw '.s:buf -endfunction - -if has('nvim-0.4.0') || has("patch-8.2.0191") - let g:peekaboo_window = "call CreateCenteredFloatingWindow()" -else " Fallback to a split window - let g:peekaboo_window={"window": "vert bo 30new"} -endif diff --git a/nvim/.config/nvim/plugin/vim-polyglot.vim b/nvim/.config/nvim/plugin/vim-polyglot.vim deleted file mode 100644 index 75ba9c0..0000000 --- a/nvim/.config/nvim/plugin/vim-polyglot.vim +++ /dev/null @@ -1,7 +0,0 @@ -" PLUGIN: vim-polyglot -" -" we disable markdown so that every markdown file can be given pandoc type -" let g:polyglot_disabled = ['markdown'] - -au BufNewFile,BufRead *.{md,mdown,mkd,mkdn,markdown,mdwn} set ft=pandoc -au BufNewFile,BufRead *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set ft=pandoc diff --git a/nvim/.config/nvim/plugin/vim-sneak.vim b/nvim/.config/nvim/plugin/vim-sneak.vim deleted file mode 100644 index 1844906..0000000 --- a/nvim/.config/nvim/plugin/vim-sneak.vim +++ /dev/null @@ -1,7 +0,0 @@ -" PLUGIN: vim-sneak -" sneak around your files using -" repeatedly pressing fFtTsS will advance the search instead of starting a new -" one. To start a new one, press any other key, then fFtTsS -let g:sneak#s_next = 1 -" use ignorecase/smartcase, depending on vim setting -let g:sneak#use_ic_scs = 1 diff --git a/nvim/.config/nvim/plugin/vim-terminator.vim b/nvim/.config/nvim/plugin/vim-terminator.vim deleted file mode 100644 index 570a3b4..0000000 --- a/nvim/.config/nvim/plugin/vim-terminator.vim +++ /dev/null @@ -1,16 +0,0 @@ -let g:terminator_clear_default_mappings = "foo bar" -let g:terminator_split_location = "vertical botright" - -nnoremap rr :TerminatorStartREPL -nnoremap rs :TerminatorStopRun - -nnoremap rt :TerminatorRunFileInTerminal -vnoremap rt :TerminatorRunPartOfFileInTerminal - -nnoremap rd :TerminatorSendDelimiterToTerminal -vnoremap rd :TerminatorSendSelectionToTerminal - -nnoremap ra :norm O# In[ ]:hh - -" lets you send fragments from jupyter-style blocks and markdown fences -let g:terminator_repl_delimiter_regex = '\(In\[.*\]:\|^```\)' diff --git a/nvim/.config/nvim/plugin/vim-tmux-navigator.vim b/nvim/.config/nvim/plugin/vim-tmux-navigator.vim deleted file mode 100644 index 7b6ba2e..0000000 --- a/nvim/.config/nvim/plugin/vim-tmux-navigator.vim +++ /dev/null @@ -1,4 +0,0 @@ -" PLUGIN: tmux-navigator -" add seamless movement between vim and tmux, switch windows with C-hjkl -" automatically save the current buffer when navigating away from vim -let g:tmux_navigator_save_on_switch = 1 diff --git a/nvim/.config/nvim/plugin/wiki.vim b/nvim/.config/nvim/plugin/wiki.vim deleted file mode 100644 index aa7eb24..0000000 --- a/nvim/.config/nvim/plugin/wiki.vim +++ /dev/null @@ -1,95 +0,0 @@ -" PLUGIN: wiki.vim -if $WIKIROOT ==? '' - let g:wiki_root = expand('~/documents/notes') -else - let g:wiki_root = $WIKIROOT -endif -" filetypes to automatically enable the plugin for, seems to take file endings -" rather than vim ft -let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki'] -let g:wiki_mappings_use_defaults = 'global' -let g:wiki_list_todos = ['[ ]', '[x]'] - -" wiki automatic link creation -" add .md to the end of links by default -let g:wiki_link_extension = '.md' -" add a link in the format [descr](target) by default -" not in wiki format [[link|descr]] -let g:wiki_link_target_type = 'md' - -" change file opening scheme of external wiki links -function! WikiFileOpen(...) abort dict - " use xdg-open for now -- can still customize if need be, see - " :help wiki-config -> g:wiki_file_open for an example - silent execute '!xdg-open' fnameescape(self.path) '&' - return 1 -endfunction -let g:wiki_file_handler = 'WikiFileOpen' - -" Zettelkasten functionality - -" Appends Zettelkasten timestamp to beginning of links -function! ZettelLinkCreate(text) abort - " lowercase and replace spaces with dashes (-) to make links uniform - let l:text=substitute(tolower(a:text), '\s\+', '-', 'g') - " prepend datestamp - let l:text=substitute(l:text, '^', s:Datestamp() . ' '. '\0', 'g') - return l:text -endfunction -" sets wiki.vim to automatically apply datestamp function to created links -let g:wiki_map_link_create = 'ZettelLinkCreate' - -let g:zettel_anchor_separator = ' ' -let g:zettel_anchor_pattern = '[:/]\d\{10,14}' -" Returns the full path to the Zettel owning the anchor id passed in -function! s:GetZettelPath(anchor) abort - " match first 10-digit-beggining file ending with .md - " e.g. 1906061330 My example-Zettel.md - let l:tomatch='/' . trim(a:anchor) . g:zettel_anchor_separator . '.*\.md' - let l:allnotes=split(globpath(g:wiki_root, '**'), '\n') - - " get absolute path - let l:matched = matchstr(l:allnotes, l:tomatch) - " make path relative to root to pass back to wiki.vim - let l:curfpath = expand('%:p:h') - let l:matched = substitute(l:matched, l:curfpath, '', '') - - return l:matched -endfunction -command! -nargs=1 ZettelOpen execute ":e " . s:GetZettelPath() - -" Uses the Zettel Anchor ID instead of the whole link structure to traverse -" the whole Wiki directory from its root and opens first fitting Zettel -function! ZettelOpenAtCursor(...) abort - let l:link = wiki#link#get() - try - let l:zettel = s:GetZettelPath( s:ExtractZettelAnchor(l:link.url) ) - - " fall back to normal link opening otherwise - if l:zettel ==? '' - call wiki#link#follow() - else - call wiki#page#follow(l:zettel) - endif - catch /E716:/ - call wiki#link#toggle(l:link) - catch /E37:/ - echoerr 'E37: Can''t open link before you''ve saved the current buffer.' - endtry -endfunction -command! ZettelOpenAtCursor :call ZettelOpenAtCursor() - -" Returns only the anchor id in a file name -" - returns empty string if nothing was found -function! s:ExtractZettelAnchor(file) abort - return trim(matchstr(a:file, g:zettel_anchor_pattern), ' \t\r:/') -endfunction - -" Creates a Zettelkasten compatible unique datestamp -function s:Datestamp() - if !exists('*strftime') - :echoerr 'Date Stamp creation needs strftime available on system!' - endif - return strftime('%y%m%d%H%M') -endfunction -command! Datestamp :echom s:Datestamp()