nvim: Switch to lua-based setup
nvim: Restructure lua config directory Restructured lua setting files, so that plugin settings are in clearly labelled as such files, and the base files are just there --- the base directory. This should also lay the ground work for modularizing plugins, so that we can enable/disable plugin groups as we need them. ---------- nvim: Remove ale linter and formatter Removed ale from plugins. Linting is being taken care of by lsp and treesitter plugins and formatting by formatter.nvim. Added all filetypes ale took care of to formatting on save. ---------- nvim: Replace wiki.vim with zettelkasten.nvim Removed lerlvag's `wiki.vim` from plugin list. Though I love it and loved using it, by now it clutters up the list and the basic functionality I need it provided by zettelkasten.nvim. (That being linking, following links, and quickly opening a central file). I may still come back to it at some point, but for now I am happy with the new setup. ---------- nvim: Add toggleterm and lazygit integration Added toggleterm plugin, integrating a very quick access to the neovim terminal (`<leader>=` mapping). Additionally, added a command to quickly call up a lazygit floating windows with the same plugin. `<leader>G` will open a git management window in which you can stage, remove, commit, push, pull and more. ---------- nvim: Replace surround, sneak; Add treesitter, dial Replaced vim-sneak with lightspeed lua plugin, which accomplishes similar to the same goal, with a little more flexibility (can also be used to replicate other vim plugins like e.g. easymotion). For now I am using it as a straight replacement, with the same fF/tT functionality stretching over multiple lines, and quick sS 2-letter jumps to any location ahead/back. The highlighting is noticeably more stable and faster. For now it is set to always highlight the next 5 occurences of a letter, wherever they are. Lastly, it does not -- so the lightspeed author -- change the buffer in any way which is what happened with sneak (due to vimscript limitations) and which can and did confuse things like treesitter and the lsp integration. Replaced vim-surround with a lua-equivalent surround.nvim. This one I am less sure about, the lua pluging, while working, still carries some bugs and does not seem as thoroughly tested. It still has problems with surrounding stuff with e.g. `*` and does not deal well with some quotation situations. I will try to keep using it and perhaps find the time to contribute to some of the issues instead of going back at first however, purely since I am a much bigger fan of the plugin existing in luascript. Replaced vim-peekaboo with registers, another switch to a lua plugin, which also functions slightly differently however. I much prefer the lua plugins display of register contents which simply appear as a dropdown, compe-like, and I can either paste with the correct symbol choice as always, or by scrolling through it as if it is an autocomplete choice. Added dial.nvim which slightly extends the functionality of ^a and ^x number in-/decreases. It should barely be noticeable in normal operation but now the combination can be used to change dates, alphabet characters, hex codes and some more. Most prominently, I am using it for date manipulation. Added a couple of treesitter related plugins: treesitter-context shows the context the cursor is currently in if the beginning of this context goes off-screen, e.g. the function beginning or current class being edited. Works for nested contexts. treesitter-textsubjects allows selecting units of codes by going up the tree branches. So, first you select an argument, then the whole argument chain, then the function definition, then the whole function, then the containing class, and so on. It is quite natural, however, I have so far only made it work for visual selection, so not as a motion target. Still, very useful - works with `v.` and can be repeated with `.`. Lastly, ts-context-commentstring improves the correct selection of commenting type for commenting plugins (i.e. my `gcc` mapping), by making use of treesitter where available. Can even do multi-language files like vue, react, or tsx modules with html, css and javascript interweaved. ---------- nvim: Add code formatter Added code formatter in lua, right now supporting python, cpp, javascript, lua, rust. More can very easily be added. I am not sure if this plugin supports the formatting of code within snippets in another file format (lukas-reineke/format.nvim does support this, but seems not-maintained). ---------- nvim: Add tmux, snippet completion Added (for real this time) tmux adjacent buffer completion. Added vsnip completion through compe: Invoke a completion (shown in compe with snippet preview) through <cr> or <space-cr> and then use <tab> and <s-tab> to go back and forth through the completable positions for the respective snippet. Many default snippets included through the community repository of friendly-snippets. ---------- nvim: Improve compe completion, Add outline view Added outline view to neovim, similar to the well-known vista.vim plugin. Can be opened (and closed again) with <leader>o mapping, simply mnemonic for 'outline'. Added unicode symbols (invoked with '\') and tmux adjacent buffers to compe completion sources. ---------- nvim: Add zen writing mode in lua Switched from goyo to TrueZen.nvim in looking for a lua replacement of zen writing modes. The F11 shortcut remains the same, additionally using F10 shortcut to enter a less drastic minimal mode. ---------- nvim: Switch keymaps to lua format Using cartographer to make setting keymaps easy. ---------- nvim: Add tmux Navigator lua replacement ---------- nvim: Add autopairs, zen writing lua plugins Switch goyo and autopairs to make use of lua plugins. Moved most of the plugin setup code from a custom and manually updated array being called from init.lua, to their respective plugin installations in plugins.lua (so, wherever the plugin is installed also contains the call of the configuration code). This should hopefully reduce duplication a little and may prepare for the lua plugin setups to end up in plugins directory of neovim. ---------- nvim: Add lua statusline, base16, async grep Added galaxyline in an initial iteration which is probably overloaded but integrates well with the also moved over to lua base16 colorschemes. For now, it is possible to, at any point, simply call the `:lua B16theme('themename')` command to change the colorscheme of both neovim itself and the galaxyline with it. The statusline, as of now, includes the activated mode (of course), the filename being edited, the edit state (whether changed from last save, or read-only), the current git branch if any, as well as the amount of added, modified, and deleted lines from current git commit. On the right hand side it contains the lsp status (if connected), the amount of errors and warnings in current file, the filetype currently recognized for the file, as well as the usual cursor position in the window. Added some small other things, including an asynchronous fuzzy-backed full-text search through telescope, which should hopefully make full-text searching much more responsive than before; updated the version of indentline to the correct one; and disabled some unused vim built-in plugins.
This commit is contained in:
parent
8d399ed872
commit
bc046d02df
47 changed files with 1043 additions and 992 deletions
|
@ -76,6 +76,7 @@ jabref-latest
|
||||||
jiq
|
jiq
|
||||||
jpdftweak
|
jpdftweak
|
||||||
jq
|
jq
|
||||||
|
lazygit
|
||||||
libdvdcss
|
libdvdcss
|
||||||
licenses
|
licenses
|
||||||
linux-firmware
|
linux-firmware
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
:Prose
|
|
|
@ -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()
|
|
|
@ -3,36 +3,40 @@
|
||||||
local augroup = require("helpers.augroup")
|
local augroup = require("helpers.augroup")
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
|
|
||||||
require('base.settings')
|
require('settings')
|
||||||
require('base.look')
|
require('plugins')
|
||||||
require('base.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
|
-- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to
|
||||||
augroup({
|
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', '/dev/shm/gopass.*',
|
||||||
{ 'BufNewFile,BufRead', '$TMPDIR/pass.?*/?*.txt', 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=' },
|
'setlocal noswapfile nobackup noundofile nowritebackup viminfo='
|
||||||
{ 'BufNewFile,BufRead', '/tmp/pass.?*/?*.txt', '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')
|
}, 'passnoleak')
|
||||||
|
|
||||||
-- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330)
|
-- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330)
|
||||||
augroup({
|
augroup({{'VimEnter', '*', 'silent exec "!kill -s SIGWINCH $PPID"'}}, 'fixsize')
|
||||||
{ '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)
|
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
|
|
||||||
|
|
|
@ -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 <BS> <C-^>
|
|
||||||
|
|
||||||
" since u undoes, would it not make sense that U redoes?
|
|
||||||
nnoremap U <C-r>
|
|
||||||
|
|
||||||
" 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 <expr> k (v:count == 0 ? 'gk' : 'k')
|
|
||||||
nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
|
|
||||||
|
|
||||||
" move around between matching brackets with tab
|
|
||||||
nnoremap <tab> %
|
|
||||||
nnoremap <tab> %
|
|
||||||
|
|
||||||
" when in insertion mode, C-u uppercases the current word, C-l lowercases it,
|
|
||||||
inoremap <C-U> <esc>gUiw`]a
|
|
||||||
inoremap <C-u> <esc>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' <bar> edit!
|
|
||||||
|
|
||||||
" yank filename to f buffer
|
|
||||||
nnoremap yf :let @f = expand("%")<cr>
|
|
||||||
|
|
||||||
" repeat the last substitute command with all its flags preserved
|
|
||||||
noremap &
|
|
||||||
\ :&&<CR>
|
|
||||||
ounmap &
|
|
||||||
sunmap &
|
|
||||||
|
|
||||||
" bracket pairings to go to the next/previous of:
|
|
||||||
" (works with count prefixes)
|
|
||||||
"
|
|
||||||
" Argument list
|
|
||||||
nnoremap [a
|
|
||||||
\ :previous<CR>
|
|
||||||
nnoremap ]a
|
|
||||||
\ :next<CR>
|
|
||||||
" Buffers
|
|
||||||
nnoremap [b
|
|
||||||
\ :bprevious<CR>
|
|
||||||
nnoremap ]b
|
|
||||||
\ :bnext<CR>
|
|
||||||
" Quickfix list
|
|
||||||
nnoremap [c
|
|
||||||
\ :cprevious<CR>
|
|
||||||
nnoremap ]c
|
|
||||||
\ :cnext<CR>
|
|
||||||
" Location list
|
|
||||||
nnoremap [l
|
|
||||||
\ :lprevious<CR>
|
|
||||||
nnoremap ]l
|
|
||||||
\ :lnext<CR>
|
|
||||||
|
|
||||||
" set our leader key to space since with hjkl, space is largely useless
|
|
||||||
let mapleader = "\<Space>"
|
|
||||||
" 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 <leader>/ :noh<cr>
|
|
||||||
|
|
||||||
" split buffers vertically/horizontally with the leader \ or - (mirrors my
|
|
||||||
" tmux setup)
|
|
||||||
nnoremap <leader>- :sp<cr>
|
|
||||||
nnoremap <leader>\ :vsp<cr>
|
|
||||||
" 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it)
|
|
||||||
nnoremap <leader>t :vsp .<cr>
|
|
||||||
" open actual new tab with leader-T
|
|
||||||
nnoremap <leader>T :tabedit .<cr>
|
|
||||||
|
|
||||||
" select the whole buffer with <leader>-a
|
|
||||||
nnoremap <leader>a ggVG
|
|
||||||
|
|
||||||
" CONFIG EDITING
|
|
||||||
" quickly edit vimrc with leader+V
|
|
||||||
nnoremap <leader>V :vsp $MYVIMRC<cr>
|
|
||||||
" 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 <leader>VV :source $MYVIMRC<cr>
|
|
||||||
|
|
||||||
" PLUGIN: vim-sneak
|
|
||||||
map f <Plug>Sneak_f
|
|
||||||
map F <Plug>Sneak_F
|
|
||||||
map t <Plug>Sneak_t
|
|
||||||
map T <Plug>Sneak_T
|
|
||||||
|
|
||||||
" PLUGIN: Vifm.vim
|
|
||||||
" open/close file tree with leader-e
|
|
||||||
nnoremap <leader>e :Vifm getcwd()<CR>
|
|
||||||
" open current file tree with current file directory
|
|
||||||
nnoremap <leader>E :Vifm<CR>
|
|
||||||
|
|
||||||
" PLUGIN: Telescope GLOBAL FUZZY FINDING
|
|
||||||
" buffers and files in current workdir
|
|
||||||
noremap <leader>s :lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>
|
|
||||||
" most recently used / MRU, bound to S since it is essentially a larger
|
|
||||||
" go-back intention than just buffers
|
|
||||||
noremap <leader>S :lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>
|
|
||||||
" fuzzy find files in cwd
|
|
||||||
noremap <leader>f :lua require 'telescope.builtin'.find_files({follow=true, hidden=true})<cr>
|
|
||||||
" general full-text search in cwd with rg
|
|
||||||
noremap <leader>F :lua require 'telescope.builtin'.live_grep()<cr>
|
|
||||||
|
|
||||||
" git status
|
|
||||||
noremap <leader>gs :lua require 'telescope.builtin'.git_status()<cr>
|
|
||||||
" git buffercommits
|
|
||||||
noremap <leader>gb :lua require 'telescope.builtin'.git_bcommits()<cr>
|
|
||||||
" git commitlog
|
|
||||||
noremap <leader>gl :lua require 'telescope.builtin'.git_commits()<cr>
|
|
||||||
|
|
||||||
" helptags
|
|
||||||
noremap <leader><F1> :lua require 'telescope.builtin'.help_tags()<cr>
|
|
||||||
" manpages
|
|
||||||
noremap <leader><F2> :lua require 'telescope.builtin'.man_pages()<cr>
|
|
||||||
|
|
||||||
" colorschemes
|
|
||||||
nnoremap <leader><F8> :lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>
|
|
||||||
|
|
||||||
" spell suggestions
|
|
||||||
nnoremap z= :lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>
|
|
||||||
|
|
||||||
" 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 <leader>n :NV<cr>
|
|
||||||
noremap <leader>N :NV!<cr>
|
|
||||||
" PLUGIN: CtrlSF
|
|
||||||
" (non-fuzzy) search in wiki with ctrlsf, in fullscreen window
|
|
||||||
nnoremap <leader>wF :execute(":call SearchNotes()")<cr>
|
|
||||||
" 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 <leader>wf :WikiFzfPages<cr>
|
|
||||||
nnoremap <leader>wt :WikiFzfTags<cr>
|
|
||||||
" use default TOC shortcut for viewing wikitoc if in correct filetype
|
|
||||||
augroup wikitoc
|
|
||||||
autocmd!
|
|
||||||
autocmd Filetype markdown,pandoc nnoremap <buffer> gO :WikiFzfToc<cr>
|
|
||||||
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 = {
|
|
||||||
\ '<plug>(wiki-link-next)' : '<tab>',
|
|
||||||
\ '<plug>(wiki-link-prev)' : '<s-tab>',
|
|
||||||
\ '<plug>(wiki-link-return)' : '<bs>',
|
|
||||||
\ 'v_<plug>(wiki-link-toggle-visual)' : '<cr>',
|
|
||||||
\ '<plug>(wiki-graph-find-backlinks)' : '<leader>wb',
|
|
||||||
\ '<plug>(wiki-graph-in)' : '<leader>wg',
|
|
||||||
\ '<plug>(wiki-graph-out)' : '<leader>wG',
|
|
||||||
\}
|
|
||||||
" additional zettelkasten mapping
|
|
||||||
augroup zettelkasten
|
|
||||||
autocmd!
|
|
||||||
autocmd Filetype markdown,pandoc nnoremap <cr> :lua require 'zettelkasten'.open_or_make_link()<cr>
|
|
||||||
autocmd Filetype markdown,pandoc vnoremap <cr> :lua require 'zettelkasten'.open_or_make_link(true)<cr>
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
" Mostly dealing with Prose writing from here on out
|
|
||||||
" Format current Paragraph (esp useful in prose writing)
|
|
||||||
nnoremap <silent> <localleader>q gqap
|
|
||||||
xnoremap <silent> <localleader>q gq
|
|
||||||
nnoremap <silent> <localleader>Q vapJgqap
|
|
||||||
|
|
||||||
" PLUGIN: GOYO
|
|
||||||
" Enter distraction free prose mode with F11
|
|
||||||
noremap <F11> :Goyo<CR>
|
|
||||||
|
|
||||||
" PLUGIN: fzf-bibtex
|
|
||||||
" map @@ to automatically insert citation reference at cursor
|
|
||||||
inoremap <silent> @@ <c-g>u<c-o>:CiteRef<CR>
|
|
||||||
" map <leader>cc to insert a complete citation at cursor
|
|
||||||
nnoremap <silent> <localleader>cc :CiteRef<cr>
|
|
||||||
" map <leader>cm to insert markdown prettified citation
|
|
||||||
nnoremap <silent> <localleader>cm :CiteMarkdown<cr>
|
|
||||||
|
|
||||||
" SPELL CHECKING
|
|
||||||
" Spell check set to <leader>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 <leader>Z :setlocal spell! spelllang=en_us<CR>
|
|
||||||
noremap <leader>ZE :setlocal spell! spelllang=en_us<CR>
|
|
||||||
noremap <leader>ZG :setlocal spell! spelllang=de_de<CR>
|
|
||||||
noremap <leader>zz 1z=
|
|
||||||
|
|
||||||
" PLUGIN: tq thesaurus_query.vim
|
|
||||||
nnoremap <leader>zt :ThesaurusQueryReplaceCurrentWord<cr>
|
|
||||||
vnoremap <leader>zt "ky:ThesaurusQueryReplace <cr>k<cr>
|
|
||||||
|
|
||||||
" 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 <localleader>dp :DocCompile<cr>
|
|
||||||
nnoremap <localleader>dP :DocCompile!<cr>
|
|
||||||
nnoremap <localleader>do :DocOpen<cr>
|
|
||||||
nnoremap <localleader>dO :DocOpen!<cr>
|
|
||||||
|
|
||||||
" PLUGIN: easy-align
|
|
||||||
" Start interactive EasyAlign in visual mode (e.g. vipga)
|
|
||||||
xmap ga <Plug>(EasyAlign)
|
|
||||||
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
|
|
||||||
nmap ga <Plug>(EasyAlign)
|
|
|
@ -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", "<cmd>lua require 'lspsaga.provider'.lsp_finder()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "gd", "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "gE", "<cmd>lua require 'lspsaga.codeaction'.code_action()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("v", "gE", "<cmd>'<,'>lua require 'lspsaga.codeaction'.range_code_action()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "K", "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "gK", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "gr", "<cmd>lua require('lspsaga.rename').rename()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
|
|
||||||
api.nvim_set_keymap("n", "ge", "<cmd>lua require('lspsaga.diagnostic').show_line_diagnostics()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "]e", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "[e", "<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
|
|
||||||
api.nvim_set_keymap("n", "C-f", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>",
|
|
||||||
{noremap = true, silent = true})
|
|
||||||
api.nvim_set_keymap("n", "C-b", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>",
|
|
||||||
{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 = '<cr>',
|
|
||||||
split = 's',
|
|
||||||
vsplit = 'v',
|
|
||||||
quit = '<esc>',
|
|
||||||
scroll_down = '<c-f>',
|
|
||||||
scroll_up = '<c-b>'
|
|
||||||
},
|
|
||||||
code_action_keys = {
|
|
||||||
quit = '<esc>',
|
|
||||||
exec = '<cr>'
|
|
||||||
},
|
|
||||||
rename_action_keys = {
|
|
||||||
quit = '<esc>',
|
|
||||||
exec = '<cr>'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
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", "<C-Space>", "compe#complete()", {expr = true, silent = true})
|
|
|
@ -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")
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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')
|
|
|
@ -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 '', @, <C-R>
|
|
||||||
|
|
||||||
-- 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
|
|
||||||
)
|
|
|
@ -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
|
|
16
nvim/.config/nvim/lua/look.lua
Normal file
16
nvim/.config/nvim/lua/look.lua
Normal file
|
@ -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')
|
263
nvim/.config/nvim/lua/maps.lua
Normal file
263
nvim/.config/nvim/lua/maps.lua
Normal file
|
@ -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['<BS>'] = '<C-^>'
|
||||||
|
|
||||||
|
-- since u undoes, would it not make sense that U redoes?
|
||||||
|
map.n.nore['U'] = '<C-r>'
|
||||||
|
|
||||||
|
-- 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['<tab>'] = '%'
|
||||||
|
|
||||||
|
-- when in insertion mode, C-u uppercases the current word, C-l lowercases it,
|
||||||
|
map.i.nore['<C-u>'] = '<esc>gUiw`]a'
|
||||||
|
map.i.nore['<C-l>'] = '<esc>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' <bar> edit!]]
|
||||||
|
|
||||||
|
-- yank filename to f buffer
|
||||||
|
map.n.nore['yf'] = ':let @f = expand("%")<cr>'
|
||||||
|
|
||||||
|
-- repeat the last substitute command with all its flags preserved
|
||||||
|
map.n.nore['&'] = ':&&<cr>'
|
||||||
|
|
||||||
|
-- bracket pairings to go to the next/previous of:
|
||||||
|
-- (works with count prefixes)
|
||||||
|
-- Argument list
|
||||||
|
map.n.nore['[a'] = ':previous<cr>'
|
||||||
|
map.n.nore[']a'] = ':next<cr>'
|
||||||
|
-- Buffers
|
||||||
|
map.n.nore['[b'] = ':bprevious<cr>'
|
||||||
|
map.n.nore[']b'] = ':bnext<cr>'
|
||||||
|
-- Quickfix list
|
||||||
|
map.n.nore['[c'] = ':cprevious<cr>'
|
||||||
|
map.n.nore[']c'] = ':cnext<cr>'
|
||||||
|
-- Location list
|
||||||
|
map.n.nore['[l'] = ':lprevious<cr>'
|
||||||
|
map.n.nore[']l'] = ':lnext<cr>'
|
||||||
|
-- Hunks (from gitsigns)
|
||||||
|
map.n.nore.expr['[h'] =
|
||||||
|
[[&diff ? ']c' : '<cmd>lua require("gitsigns.actions").prev_hunk()<CR>']]
|
||||||
|
map.n.nore.expr[']h'] =
|
||||||
|
[[&diff ? '[c' : '<cmd>lua require("gitsigns.actions").next_hunk()<CR>']]
|
||||||
|
|
||||||
|
-- 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['<leader>/'] = ':noh<cr>'
|
||||||
|
|
||||||
|
-- split buffers vertically/horizontally with the leader \ or - (mirrors my
|
||||||
|
-- tmux setup)
|
||||||
|
map.n.nore['<leader>-'] = ':sp<cr>'
|
||||||
|
map.n.nore['<leader>\\'] = ':vsp<cr>'
|
||||||
|
-- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it)
|
||||||
|
map.n.nore['<leader>t'] = ':vsp .<cr>'
|
||||||
|
-- open actual new tab with leader-T
|
||||||
|
map.n.nore['<leader>T'] = ':tabedit .<cr>'
|
||||||
|
|
||||||
|
-- select the whole buffer with <leader>-a
|
||||||
|
map.n.nore['<leader>a'] = 'ggVG'
|
||||||
|
|
||||||
|
-- CONFIG EDITING
|
||||||
|
-- quickly edit vimrc with leader+V
|
||||||
|
map.n.nore['<leader>V'] = ':vsp $MYVIMRC<cr>'
|
||||||
|
-- source vimrc with keystroke combination
|
||||||
|
map.n.nore['<leader>VV'] = ':source $MYVIMRC<cr>'
|
||||||
|
|
||||||
|
-- PLUGIN: Vifm.vim
|
||||||
|
-- open/close file tree with leader-e
|
||||||
|
map.n.nore['<leader>e'] = ':Vifm<cr>'
|
||||||
|
-- open current file tree with current file directory
|
||||||
|
map.n.nore['<leader>E'] = ':Vifm getcwd()<cr>'
|
||||||
|
|
||||||
|
-- PLUGIN: Telescope GLOBAL FUZZY FINDING
|
||||||
|
-- buffers and files in current workdir
|
||||||
|
map.n.nore['<leader>s'] =
|
||||||
|
[[:lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>]]
|
||||||
|
-- most recently used / MRU, bound to S since it is essentially a larger
|
||||||
|
-- go-back intention than just buffers
|
||||||
|
map.n.nore['<leader>S'] =
|
||||||
|
[[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>]]
|
||||||
|
-- fuzzy find files in cwd
|
||||||
|
map.n.nore['<leader>f'] =
|
||||||
|
[[:lua require 'telescope.builtin'.find_files({follow=true, hidden=true})<cr>]]
|
||||||
|
-- general full-text search in cwd with rg
|
||||||
|
map.n.nore['<leader>F'] =
|
||||||
|
[[:lua require 'telescope'.extensions.fzf_writer.grep()<cr>]]
|
||||||
|
|
||||||
|
-- git status
|
||||||
|
map.n.nore['<leader>gs'] = [[:lua require 'telescope.builtin'.git_status()<cr>]]
|
||||||
|
-- git buffercommits
|
||||||
|
map.n.nore['<leader>gb'] =
|
||||||
|
[[:lua require 'telescope.builtin'.git_bcommits()<cr>]]
|
||||||
|
-- git commitlog
|
||||||
|
map.n.nore['<leader>gl'] =
|
||||||
|
[[:lua require 'telescope.builtin'.git_commits()<cr>]]
|
||||||
|
|
||||||
|
-- helptags
|
||||||
|
map.n.nore['<leader><F1>'] =
|
||||||
|
[[:lua require 'telescope.builtin'.help_tags()<cr>]]
|
||||||
|
-- manpages
|
||||||
|
map.n.nore['<leader><F2>'] =
|
||||||
|
[[:lua require 'telescope.builtin'.man_pages()<cr>]]
|
||||||
|
|
||||||
|
-- colorschemes
|
||||||
|
map.n.nore['<leader><F8>'] =
|
||||||
|
[[:lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>]]
|
||||||
|
|
||||||
|
-- spell suggestions
|
||||||
|
map.n.nore['z='] =
|
||||||
|
[[:lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>]]
|
||||||
|
|
||||||
|
-- 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['<leader>n'] = ':NV<cr>'
|
||||||
|
map.n.nore['<leader>N'] = ':NV!<cr>'
|
||||||
|
|
||||||
|
-- PLUGIN: CtrlSF
|
||||||
|
-- (non-fuzzy) search in wiki with ctrlsf, in fullscreen window
|
||||||
|
map.n.nore['<leader>wf'] = ':call SearchNotes()<cr>'
|
||||||
|
|
||||||
|
-- Mostly dealing with Prose writing from here on out
|
||||||
|
-- Format current Paragraph (esp useful in prose writing)
|
||||||
|
map.n.nore.silent['<localleader>q'] = 'gqap'
|
||||||
|
map.x.nore.silent['<localleader>q'] = 'gq'
|
||||||
|
map.n.nore.silent['<localleader>Q'] = 'vapJgqap'
|
||||||
|
|
||||||
|
-- Enter distraction free prose mode with F11
|
||||||
|
map.n.nore.silent['<F11>'] = ':TZAtaraxis<cr>'
|
||||||
|
map.n.nore.silent['<F10>'] = ':TZMinimalist<cr>'
|
||||||
|
|
||||||
|
-- PLUGIN: fzf-bibtex
|
||||||
|
-- map @@ to automatically insert citation reference at cursor
|
||||||
|
map.i.nore.silent['@@'] = '<c-g>u<c-o>:CiteRef<cr>'
|
||||||
|
-- map <leader>cc to insert a complete citation at cursor
|
||||||
|
map.n.nore.silent['<leader>cc'] = ':CiteRef<cr>'
|
||||||
|
-- map <leader>cm to insert markdown prettified citation
|
||||||
|
map.n.nore.silent['<localleader>cm'] = ':CiteMarkdown<cr>'
|
||||||
|
|
||||||
|
-- SPELL CHECKING
|
||||||
|
-- Spell check set to <leader>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['<leader>Z'] = ':setlocal spell! spelllang=en_us,de_de<cr>'
|
||||||
|
map.n.nore['<leader>ZE'] = ':setlocal spell! spelllang=en_us<cr>'
|
||||||
|
map.n.nore['<leader>ZG'] = ':setlocal spell! spelllang=en_us<cr>'
|
||||||
|
map.n.nore['<leader>zz'] = '1z='
|
||||||
|
|
||||||
|
-- PLUGIN: tq thesaurus_query.vim
|
||||||
|
-- nnoremap <leader>zt :ThesaurusQueryReplaceCurrentWord<cr>
|
||||||
|
map.n.nore['<leader>zt'] = ':ThesaurusQueryReplaceCurrentWord<cr>'
|
||||||
|
map.v.nore['<leader>zt'] = '"ky:ThesaurusQueryReplace <cr>k<cr>'
|
||||||
|
|
||||||
|
-- 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['<leader>dp'] = ':DocCompile<cr>'
|
||||||
|
map.n.nore['<leader>dP'] = ':DocCompile!<cr>'
|
||||||
|
map.n.nore['<leader>do'] = ':DocOpen<cr>'
|
||||||
|
map.n.nore['<leader>dO'] = ':DocOpen!<cr>'
|
||||||
|
|
||||||
|
-- PLUGIN: easy-align
|
||||||
|
-- Start interactive EasyAlign in visual mode (e.g. vipga)
|
||||||
|
map.x['ga'] = '<Plug>(EasyAlign)'
|
||||||
|
-- Start interactive EasyAlign for a motion/text object (e.g. gaip)
|
||||||
|
map.n['ga'] = '<Plug>(EasyAlign)'
|
||||||
|
|
||||||
|
-- PLUGIN: Navigator.nvim
|
||||||
|
map.n.nore.silent['<c-h>'] = "<CMD>lua require('Navigator').left()<CR>"
|
||||||
|
map.n.nore.silent['<c-k>'] = "<CMD>lua require('Navigator').up()<CR>"
|
||||||
|
map.n.nore.silent['<c-l>'] = "<CMD>lua require('Navigator').right()<CR>"
|
||||||
|
map.n.nore.silent['<c-j>'] = "<CMD>lua require('Navigator').down()<CR>"
|
||||||
|
map.n.nore.silent['<c-p>'] = "<CMD>lua require('Navigator').previous()<CR>"
|
||||||
|
|
||||||
|
-- PLUGIN: compe.nvim
|
||||||
|
-- lsp keymaps are set in lsp settings, only for lsp buffers
|
||||||
|
map.i.nore.expr.silent['<c-space>'] = 'compe#complete()'
|
||||||
|
map.i.expr['<Tab>'] =
|
||||||
|
[[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']]
|
||||||
|
map.i.expr['<S-Tab>'] =
|
||||||
|
[[vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>']]
|
||||||
|
|
||||||
|
-- PLUGIN: symbols-outline.nvim
|
||||||
|
map.n.nore.silent['<leader>o'] = "<cmd>SymbolsOutline<cr>"
|
||||||
|
|
||||||
|
-- PLUGIN: dial-increment
|
||||||
|
map.n['<c-a>'] = '<Plug>(dial-increment)'
|
||||||
|
map.n['<c-x>'] = '<Plug>(dial-decrement)'
|
||||||
|
map.v['<c-a>'] = '<Plug>(dial-increment)'
|
||||||
|
map.v['<c-x>'] = '<Plug>(dial-decrement)'
|
||||||
|
map.v['g<c-a>'] = '<Plug>(dial-increment-additional)'
|
||||||
|
map.v['g<c-x>'] = '<Plug>(dial-decrement-additional)'
|
||||||
|
|
||||||
|
-- PLUGIN: zettelkasten.nvim
|
||||||
|
map.n.nore['<cr>'] =
|
||||||
|
[[:silent lua require 'zettelkasten'.open_or_make_link()<cr>]]
|
||||||
|
map.v.nore['<cr>'] = [[:lua require 'zettelkasten'.open_or_make_link(true)<cr>]]
|
||||||
|
map.n.nore['<leader>ww'] = [[:lua require 'zettelkasten'.open_index()<cr> ]]
|
||||||
|
|
||||||
|
-- PLUGIN: toggleterm.nvim
|
||||||
|
-- create a lazygit window, set up in toggleterm settings
|
||||||
|
map.n.nore['<leader>G'] = ':Lazygit<cr>'
|
16
nvim/.config/nvim/lua/plug/_autopair.lua
Normal file
16
nvim/.config/nvim/lua/plug/_autopair.lua
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
require('nvim-autopairs').setup({check_ts = true})
|
||||||
|
require("nvim-autopairs.completion.compe").setup({
|
||||||
|
map_cr = true, -- map <CR> 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)
|
||||||
|
}
|
70
nvim/.config/nvim/lua/plug/_format.lua
Normal file
70
nvim/.config/nvim/lua/plug/_format.lua
Normal file
|
@ -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', '<buffer>',
|
||||||
|
'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
|
||||||
|
}
|
||||||
|
})
|
244
nvim/.config/nvim/lua/plug/_galaxyline.lua
Normal file
244
nvim/.config/nvim/lua/plug/_galaxyline.lua
Normal file
|
@ -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)
|
|
@ -1,14 +1,14 @@
|
||||||
-- Settings for indentBlankline
|
-- Settings for indentBlankline
|
||||||
-- turn off for diff views since we want to compare directly
|
-- turn off for diff views since we want to compare directly
|
||||||
if vim.wo.diff then
|
if vim.wo.diff then
|
||||||
vim.g["indent_blakline_enabled"] = false
|
vim.g["indent_blankline_enabled"] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.g.indent_blankline_char = "▏"
|
vim.g.indent_blankline_char = "▏"
|
||||||
|
|
||||||
vim.g.indent_blankline_filetype_exclude = {
|
vim.g.indent_blankline_filetype_exclude = {
|
||||||
"help", "undotree",
|
"help", "undotree",
|
||||||
"markdown", "text", "pandoc",
|
"markdown", "text", "pandoc", "rst", "asciidoc",
|
||||||
"vim-plug"
|
"vim-plug"
|
||||||
}
|
}
|
||||||
vim.g.indent_blankline_buftype_exclude = {"terminal"}
|
vim.g.indent_blankline_buftype_exclude = {"terminal"}
|
147
nvim/.config/nvim/lua/plug/_lsp.lua
Normal file
147
nvim/.config/nvim/lua/plug/_lsp.lua
Normal file
|
@ -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",
|
||||||
|
"<cmd>lua require 'lspsaga.provider'.lsp_finder()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "gd",
|
||||||
|
"<cmd>lua require'lspsaga.provider'.preview_definition()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "gE",
|
||||||
|
"<cmd>lua require 'lspsaga.codeaction'.code_action()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("v", "gE",
|
||||||
|
"<cmd>'<,'>lua require 'lspsaga.codeaction'.range_code_action()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "K",
|
||||||
|
"<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "gK",
|
||||||
|
"<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "gr",
|
||||||
|
"<cmd>lua require('lspsaga.rename').rename()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
|
||||||
|
api.nvim_set_keymap("n", "ge",
|
||||||
|
"<cmd>lua require('lspsaga.diagnostic').show_line_diagnostics()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "]e",
|
||||||
|
"<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_next()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "[e",
|
||||||
|
"<cmd>lua require('lspsaga.diagnostic').lsp_jump_diagnostic_prev()<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
|
||||||
|
api.nvim_set_keymap("n", "C-f",
|
||||||
|
"<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>",
|
||||||
|
{noremap = true, silent = true})
|
||||||
|
api.nvim_set_keymap("n", "C-b",
|
||||||
|
"<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>",
|
||||||
|
{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 = '<cr>',
|
||||||
|
split = 's',
|
||||||
|
vsplit = 'v',
|
||||||
|
quit = '<esc>',
|
||||||
|
scroll_down = '<c-f>',
|
||||||
|
scroll_up = '<c-b>'
|
||||||
|
},
|
||||||
|
code_action_keys = {quit = '<esc>', exec = '<cr>'},
|
||||||
|
rename_action_keys = {quit = '<esc>', exec = '<cr>'}
|
||||||
|
}
|
||||||
|
vim.cmd("command! LspHover lua vim.lsp.buf.hover()<CR>")
|
||||||
|
vim.cmd(
|
||||||
|
"command! LspDisable lua vim.lsp.stop_client(vim.lsp.get_active_clients())<CR>")
|
||||||
|
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()
|
32
nvim/.config/nvim/lua/plug/_telescope.lua
Normal file
32
nvim/.config/nvim/lua/plug/_telescope.lua
Normal file
|
@ -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")
|
18
nvim/.config/nvim/lua/plug/_toggleterm.lua
Normal file
18
nvim/.config/nvim/lua/plug/_toggleterm.lua
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require("toggleterm").setup {
|
||||||
|
open_mapping = [[<leader>=]],
|
||||||
|
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()<cr>]])
|
||||||
|
|
||||||
|
-- vim.api.nvim_set_keymap("n", "<leader>g", "<cmd>lua _lazygit_toggle()<CR>",
|
||||||
|
-- {noremap = true, silent = true})
|
14
nvim/.config/nvim/lua/plug/_treesitter.lua
Normal file
14
nvim/.config/nvim/lua/plug/_treesitter.lua
Normal file
|
@ -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}
|
||||||
|
}
|
173
nvim/.config/nvim/lua/plugins.lua
Normal file
173
nvim/.config/nvim/lua/plugins.lua
Normal file
|
@ -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 '', @, <C-R>
|
||||||
|
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)
|
|
@ -1,10 +1,19 @@
|
||||||
require("helpers.vimoptions")
|
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)
|
local apply_options = function(opts)
|
||||||
for k, v in pairs(opts) do
|
for k, v in pairs(opts) do
|
||||||
vim.opt[k] = v
|
vim.opt[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local o = {
|
local o = {
|
||||||
|
@ -70,3 +79,4 @@ local o = {
|
||||||
|
|
||||||
vim.api.nvim_set_var('tex_flavor', 'latex')
|
vim.api.nvim_set_var('tex_flavor', 'latex')
|
||||||
apply_options(o)
|
apply_options(o)
|
||||||
|
disable_builtins(default_builtins_disabled)
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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(<q-args>), 1,
|
|
||||||
\ fzf#vim#with_preview(), <bang>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
|
|
|
@ -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 <SID>goyo_enter()
|
|
||||||
autocmd! User GoyoLeave nested call <SID>goyo_leave()
|
|
|
@ -1,5 +0,0 @@
|
||||||
command! LspHover lua vim.lsp.buf.hover()<CR>
|
|
||||||
command! LspDisable lua vim.lsp.stop_client(vim.lsp.get_active_clients())<CR>
|
|
||||||
|
|
||||||
" actual LSP config takes place in lua ('lua/lsp')
|
|
||||||
setlocal omnifunc=v:lua.vim.lsp.omnifunc
|
|
|
@ -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()
|
|
|
@ -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
|
|
|
@ -12,4 +12,4 @@
|
||||||
" variable to the intended filetype.
|
" variable to the intended filetype.
|
||||||
" ]]--
|
" ]]--
|
||||||
|
|
||||||
command! -nargs=? -bang ScratchPad :lua require("scratchpad").create("<bang>","<args>")
|
command! -nargs=? -bang ScratchPad :lua require("personal.scratchpad").create("<bang>","<args>")
|
||||||
|
|
|
@ -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("\<CR>")
|
|
||||||
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
|
|
|
@ -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("<cword>"))
|
|
||||||
if l:spellstatus
|
|
||||||
return fzf#run({'source': suggestions, 'sink': function("s:fzfSpellSink"), 'right': "20%" })
|
|
||||||
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command FzfSpellSuggest :call FzfSpell()<CR>
|
|
|
@ -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' : {}}
|
|
|
@ -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
|
|
|
@ -1,3 +0,0 @@
|
||||||
" PLUGIN: vim-pandoc-syntax
|
|
||||||
let g:pandoc#syntax#conceal#use = 1
|
|
||||||
let g:pandoc#syntax#conceal#urls = 1
|
|
|
@ -28,3 +28,7 @@ let g:pandoc#folding#fastfolds=1
|
||||||
let g:pandoc#spell#default_langs=["en_us", "de_de"]
|
let g:pandoc#spell#default_langs=["en_us", "de_de"]
|
||||||
let g:pandoc#hypertext#ausosave_on_edit_open_link=1
|
let g:pandoc#hypertext#ausosave_on_edit_open_link=1
|
||||||
let g:pandoc#hypertext#create_if_no_alternates_exists=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
|
||||||
|
|
|
@ -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 <buffer> 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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -1,16 +0,0 @@
|
||||||
let g:terminator_clear_default_mappings = "foo bar"
|
|
||||||
let g:terminator_split_location = "vertical botright"
|
|
||||||
|
|
||||||
nnoremap <silent> <leader>rr :TerminatorStartREPL <CR>
|
|
||||||
nnoremap <silent> <leader>rs :TerminatorStopRun <CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <leader>rt :TerminatorRunFileInTerminal <CR>
|
|
||||||
vnoremap <silent> <leader>rt :TerminatorRunPartOfFileInTerminal<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <leader>rd :TerminatorSendDelimiterToTerminal<CR>
|
|
||||||
vnoremap <silent> <leader>rd :TerminatorSendSelectionToTerminal<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <leader>ra :norm O# In[ ]:hh
|
|
||||||
|
|
||||||
" lets you send fragments from jupyter-style blocks and markdown fences
|
|
||||||
let g:terminator_repl_delimiter_regex = '\(In\[.*\]:\|^```\)'
|
|
|
@ -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
|
|
|
@ -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(<q-args>)
|
|
||||||
|
|
||||||
" 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()
|
|
Loading…
Reference in a new issue