dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 1b14012924b3058a1156577d0b9cfc196acb58bf
parent dc1f3fb35476e2ffc2c3696a21ba2218f81399da
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Fri,  3 Mar 2023 14:43:14 +0100

vim: a bunch of changes

Diffstat:
Mnvim/init.lua | 48+++++++++++++++++++++++++++++++++---------------
Mvim/abolish_save_file.vim | 6++++++
Mvim/after/ftplugin/bib.vim | 4++++
Mvim/after/ftplugin/rust.vim | 12++++++------
Avim/after/ftplugin/snippets.vim | 4++++
Mvim/after/ftplugin/tex.vim | 11++++++++++-
Avim/autoload/searchfold.vim | 13+++++++++++++
Dvim/autoload/sessions.vim | 66------------------------------------------------------------------
Mvim/colors/jokull.schemer | 1+
Mvim/colors/jokull.vim | 3++-
Mvim/colors/junipero.schemer | 1+
Mvim/colors/junipero.vim | 3++-
Dvim/idea.vimrc | 58----------------------------------------------------------
Avim/plugin/searchfold.vim | 2++
Dvim/plugin/sessions.vim | 10----------
Avim/snippets/bib.snippets | 167+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avim/snippets/tex.snippets | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avim/snippets/vim.snippets | 13+++++++++++++
Mvim/spell/en.utf-8.add | 9+++++++++
Mvim/spell/en.utf-8.add.spl | 0
Avim/ultisnips/java.snippets | 3+++
Mvim/vimrc | 163+++++++++++++++++++++++++++++++++++++++----------------------------------------
22 files changed, 462 insertions(+), 240 deletions(-)

diff --git a/nvim/init.lua b/nvim/init.lua @@ -65,6 +65,19 @@ require('packer').startup(function(use) -- Linting - for when LSP is not enough use 'mfussenegger/nvim-lint' + use { + "folke/which-key.nvim", + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + require("which-key").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end + } + -- Add custom plugins to packer from ~/.config/nvim/lua/custom/plugins.lua local has_plugins, plugins = pcall(require, 'custom.plugins') if has_plugins then @@ -108,7 +121,6 @@ vim.o.completeopt = 'menuone,noselect' -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' -- Keymaps for better default experience -- See `:help vim.keymap.set()` @@ -166,26 +178,28 @@ pcall(require('telescope').load_extension, 'fzf') -- See `:help telescope.builtin` vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '<leader>/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer]' }) +vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +-- vim.keymap.set('n', '<leader>/', function() +-- -- You can pass additional configuration to telescope to change theme, layout, etc. +-- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { +-- winblend = 10, +-- previewer = false, +-- }) +-- end, { desc = '[/] Fuzzily search in current buffer]' }) vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', '<leader>sr', require('telescope.builtin').lsp_references, { desc = '[S]earch [R]eferences' }) -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'help', 'vim', 'bash', 'ledger', 'ruby', 'python' }, + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'help', 'vim', 'bash', 'ledger', 'ruby', + 'python', 'java', 'sql'}, highlight = { enable = true }, indent = { enable = true, disable = { 'python' } }, @@ -195,7 +209,7 @@ require('nvim-treesitter.configs').setup { init_selection = '<c-space>', node_incremental = '<c-space>', scope_incremental = '<c-s>', - node_decremental = '<c-backspace>', + node_decremental = '<c-d>', }, }, textobjects = { @@ -301,14 +315,14 @@ end -- Add any additional override configuration in the following tables. They will be passed to -- the `settings` field of the server config. You must look up that documentation yourself. local servers = { - -- clangd = {}, - -- gopls = {}, - -- tsserver = {}, ruby_ls = {}, rust_analyzer = {}, bashls = {}, pyright = {}, - sumneko_lua = { + jdtls = {}, + jsonls = {}, + texlab = {}, + lua_ls = { Lua = { workspace = { checkThirdParty = false }, telemetry = { enable = false }, @@ -399,3 +413,7 @@ vim.api.nvim_create_autocmd({ "BufWritePost" }, { require("lint").try_lint() end, }) + +vim.cmd ([[ +nnoremap <leader><C-e><C-u> :<c-u>exe "vsplit ~/.vim/snippets/"..&filetype..".snippets"<CR> +]]) diff --git a/vim/abolish_save_file.vim b/vim/abolish_save_file.vim @@ -12,3 +12,9 @@ Abolish etc etc. Abolish distr{,s} distribution{,s} Abolish db{,s} database{,s} Abolish seq{,s} sequence{,s} +Abolish repo{,s} repositor{y,ies} +Abolish ds{,s} dataset{,s} +Abolish samp{,s} sample{,s} +Abolish repo{,s} repositor{y,ies} +Abolish ds{,s} dataset{,s} +Abolish samp{,s} sample{,s} diff --git a/vim/after/ftplugin/bib.vim b/vim/after/ftplugin/bib.vim @@ -1,6 +1,10 @@ command! BibOpenFile exe 'call system("open '.findfile(expand("<cfile>")).'")' nnoremap go :BibOpenFile<CR> +setlocal suffixesadd+=.pdf +let b:undo_ftplugin = (exists('b:undo_ftplugin') ? b:undo_ftplugin.'|' : '') +let b:undo_ftplugin .= 'setlocal suffixesadd<' + function! s:NextSection(backwards, visual) if a:visual normal! gv diff --git a/vim/after/ftplugin/rust.vim b/vim/after/ftplugin/rust.vim @@ -1,10 +1,10 @@ -if exists('g:loaded_dispatch') - nnoremap <buffer> <leader>mm :Make build<CR> -else - nnoremap <buffer> <leader>mm :make build<CR> -endif +" if exists('g:loaded_dispatch') +" nnoremap <buffer> <leader>mm :Make build<CR> +" else +" nnoremap <buffer> <leader>mm :make build<CR> +" endif setlocal formatprg=rustfmt setlocal keywordprg=rustup\ doc let b:undo_ftplugin = (exists('b:undo_ftplugin') ? b:undo_ftplugin.'|' : '') let b:undo_ftplugin .= 'setlocal formatprg< keywordprg<' -let b:undo_ftplugin .= '| nunmap <buffer> <leader>mm' +" let b:undo_ftplugin .= '| nunmap <buffer> <leader>mm' diff --git a/vim/after/ftplugin/snippets.vim b/vim/after/ftplugin/snippets.vim @@ -0,0 +1,4 @@ +setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab + +let b:undo_ftplugin = (exists('b:undo_ftplugin') ? b:undo_ftplugin.'|' : '') +let b:undo_ftplugin .= 'setlocal tabstop< softtabstop< shiftwidth< expandtab<' diff --git a/vim/after/ftplugin/tex.vim b/vim/after/ftplugin/tex.vim @@ -8,6 +8,11 @@ inoremap <buffer> : :<c-g>u inoremap <buffer> ; ;<c-g>u inoremap <buffer> - -<c-g>u setlocal formatoptions-=cat wrap +setlocal conceallevel=2 + +setlocal suffixesadd+=.pdf +command! BibOpenFile exe 'call system("open '.findfile(expand("<cfile>")).'")' +nnoremap go :BibOpenFile<CR> command! -buffer Todo Ag \\?((TO ?DO)|FIXME)[:{]<space>? @@ -17,6 +22,10 @@ setlocal foldexpr=vimtex#fold#level(v:lnum) setlocal foldtext=vimtex#fold#text() setlocal expandtab +nnoremap <buffer> <localleader>ln :vimgrep /newcommand/ **/*.sty **/*.tex **/*.cls<CR> + +setlocal spell spelllang=en_us + " Set up surround if exists('g:loaded_surround') let b:surround_99 = "\\\1command: \1{\r}" @@ -24,4 +33,4 @@ endif let b:undo_ftplugin = (exists('b:undo_ftplugin') ? b:undo_ftplugin.'|' : '') let b:undo_ftplugin .= 'nmapc <buffer>' let b:undo_ftplugin .= '|imapc <buffer>' -let b:undo_ftplugin .= '|setlocal formatoptions< wrap< foldmethod< foldexpr< foldtext< expandtab<' +let b:undo_ftplugin .= '|setlocal formatoptions< wrap< foldmethod< foldexpr< foldtext< expandtab< conceallevel< suffixesadd<' diff --git a/vim/autoload/searchfold.vim b/vim/autoload/searchfold.vim @@ -0,0 +1,13 @@ +" Search folding (after any regular search, this folds all non-matched lines) +function! searchfold#Toggle() abort + if exists('b:search_folded') && b:search_folded + setlocal foldexpr< foldmethod< foldenable< foldlevel< + let b:search_folded = 0 + else + setlocal foldexpr=getline(v:lnum)!~@/ + setlocal foldmethod=expr + setlocal foldenable + setlocal foldlevel=0 + let b:search_folded = 1 + endif +endfunction diff --git a/vim/autoload/sessions.vim b/vim/autoload/sessions.vim @@ -1,66 +0,0 @@ -let s:seshdir = $HOME.'/.vim/sessions/' -function! sessions#SaveSession() abort - silent call mkdir (s:seshdir, 'p') - let name = input("Save as: ") - if name == "" - echo "\nNo name provided." - else - let seshfile = s:seshdir.name.".vim" - execute "mksession! " . seshfile - echo "\nSession saved: ".seshfile - endif -endfunction -function! s:ListSessions() abort - silent call mkdir (s:seshdir, 'p') - let files = globpath(s:seshdir, '*', 0, 1) - call filter(files, '!isdirectory(v:val)') - return files -endfunction -function! s:ChooseSession() abort - let files = <SID>ListSessions() - if len(files) > 0 - let inputfiles = map(copy(files), 'index(files, v:val)+1.": ".v:val') - let response = inputlist(inputfiles) - if response > 0 - return files[response-1] - else - return "" - endif - else - echo "No sessions available." - return "" - endif -endfunction -function! sessions#LoadSession() abort - let session = <SID>ChooseSession() - if session != "" - execute 'source '.session - else - echo "\nNo session selected." - endif -endfunction -function! sessions#DeleteSession() abort - let sesh = <SID>ChooseSession() - if sesh == "" - echo "\nNo session selected" - return 1 - endif - let conf = confirm("Delete ".sesh."?", "&Yes\n&No\n", 2) - if conf == 1 - if delete(sesh) == 0 - echom "Deleted ".sesh - else - echom "Couldn't delete ".sesh - endif - else - echom "No action taken." - endif -endfunction -function! sessions#CloseSession() - bufdo! bwipeout - cd - if exists('g:loaded_tagbar') && g:loaded_tagbar == 1 - execute "TagbarClose" - endif - echom "Session closed." -endfunction diff --git a/vim/colors/jokull.schemer b/vim/colors/jokull.schemer @@ -96,6 +96,7 @@ GitGutterAdd ddarkgreen, bg GitGutterChange gold, bg GitGutterDelete darkred, bg GitGutterChangeDelete offlightred, bg +NormalFloat NONE, lightgrey " link group1,group2,... target group link structure type diff --git a/vim/colors/jokull.vim b/vim/colors/jokull.vim @@ -52,6 +52,7 @@ hi GitGutterAdd guifg=#007822 guibg=#e4e4e4 ctermfg=28 ctermbg=254 cterm=NONE gu hi GitGutterChange guifg=#8e830e guibg=#e4e4e4 ctermfg=100 ctermbg=254 cterm=NONE gui=NONE hi GitGutterDelete guifg=#6e032e guibg=#e4e4e4 ctermfg=52 ctermbg=254 cterm=NONE gui=NONE hi GitGutterChangeDelete guifg=#80537e guibg=#e4e4e4 ctermfg=96 ctermbg=254 cterm=NONE gui=NONE +hi NormalFloat guifg=NONE guibg=#d0d0d0 ctermfg=NONE ctermbg=252 cterm=NONE gui=NONE " Link definitions hi! link precondit include hi! link tag delimiter @@ -96,7 +97,7 @@ hi! link operator statement hi! link vimwikilink type hi! link specialchar delimiter " Code to clear any groups that are not defined -let s:DefinedColors=['precondit', 'tag', 'spellbad', 'spelllocal', 'gh_files_dir', 'conditional', 'markdowncode', 'netrwdir', 'gitcommitsummary', 'netrwexe', 'tabline', 'alewarningline', 'mkdlink', 'signcolumn', 'spellcap', 'spellrare', 'netrwmarkfile', 'markdownurl', 'error', 'preproc', 'aleerror', 'number', 'define', 'typedef', 'repeat', 'specialcomment', 'pmenu', 'storageclass', 'alewarning', 'gitcommitoverflow', 'macro', 'pmenusel', 'modemsg', 'aleerrorline', 'character', 'structure', 'debug', 'special', 'label', 'operator', 'vimwikilink', 'specialchar', 'normal', 'keyword', 'cursorline', 'string', 'identifier', 'function', 'statement', 'include', 'type', 'search', 'incsearch', 'folded', 'tablinefill', 'tablinesel', 'wildmenu', 'linenr', 'vertsplit', 'todo', 'nontext', 'statusline', 'statuslinenc', 'statuslinetermnc', 'statuslineterm', 'statuslinefile', 'statuslinenormmode', 'visual', 'title', 'matchparen', 'qffilename', 'delimiter', 'comment', 'errormsg', 'cursorlinenr', 'specialkey', 'constant', 'diffadd', 'diffdelete', 'diffchange', 'difftext', 'gitgutteradd', 'gitgutterchange', 'gitgutterdelete', 'gitgutterchangedelete'] +let s:DefinedColors=['precondit', 'tag', 'spellbad', 'spelllocal', 'gh_files_dir', 'conditional', 'markdowncode', 'netrwdir', 'gitcommitsummary', 'netrwexe', 'tabline', 'alewarningline', 'mkdlink', 'signcolumn', 'spellcap', 'spellrare', 'netrwmarkfile', 'markdownurl', 'error', 'preproc', 'aleerror', 'number', 'define', 'typedef', 'repeat', 'specialcomment', 'pmenu', 'storageclass', 'alewarning', 'gitcommitoverflow', 'macro', 'pmenusel', 'modemsg', 'aleerrorline', 'character', 'structure', 'debug', 'special', 'label', 'operator', 'vimwikilink', 'specialchar', 'normal', 'keyword', 'cursorline', 'string', 'identifier', 'function', 'statement', 'include', 'type', 'search', 'incsearch', 'folded', 'tablinefill', 'tablinesel', 'wildmenu', 'linenr', 'vertsplit', 'todo', 'nontext', 'statusline', 'statuslinenc', 'statuslinetermnc', 'statuslineterm', 'statuslinefile', 'statuslinenormmode', 'visual', 'title', 'matchparen', 'qffilename', 'delimiter', 'comment', 'errormsg', 'cursorlinenr', 'specialkey', 'constant', 'diffadd', 'diffdelete', 'diffchange', 'difftext', 'gitgutteradd', 'gitgutterchange', 'gitgutterdelete', 'gitgutterchangedelete', 'normalfloat'] function! s:ClearUndefinedColors(colors) let undefined_groups = filter(a:colors->keys()->map('tolower(v:val)'), 'index(s:DefinedColors, tolower(v:val)) < 0') call map(undefined_groups, "execute('highlight' . ' ' . v:val . ' ' . 'NONE')") diff --git a/vim/colors/junipero.schemer b/vim/colors/junipero.schemer @@ -77,6 +77,7 @@ GitGutterAdd #007822, darkblue. NONE GitGutterChange #8e830e, darkblue. NONE GitGutterDelete #6e032e, darkblue. NONE GitGutterChangeDelete #80537e, darkblue. NONE +NormalFloat text, #1a1a33 link Label,StorageClass,Typedef Structure link ConId,Character,VimwikiLink Constant diff --git a/vim/colors/junipero.vim b/vim/colors/junipero.vim @@ -71,6 +71,7 @@ hi GitGutterAdd guifg=#007822 guibg=#101124 ctermfg=28 ctermbg=0 cterm=NONE gui= hi GitGutterChange guifg=#8e830e guibg=#101124 ctermfg=100 ctermbg=0 cterm=NONE gui=NONE hi GitGutterDelete guifg=#6e032e guibg=#101124 ctermfg=52 ctermbg=0 cterm=NONE gui=NONE hi GitGutterChangeDelete guifg=#80537e guibg=#101124 ctermfg=96 ctermbg=0 cterm=NONE gui=NONE +hi NormalFloat guifg=#838383 guibg=#1a1a33 ctermfg=244 ctermbg=17 cterm=NONE gui=NONE " Link definitions hi! link PreCondit Include hi! link Tag Delimiter @@ -102,7 +103,7 @@ hi! link SpellBad Todo hi! link netrwDir LineNr hi! link SpecialChar Delimiter " Code to clear any groups that are not defined -let s:DefinedColors=['precondit', 'tag', 'define', 'mkdlink', 'typedef', 'vimwikilink', 'signcolumn', 'macro', 'spelllocal', 'tabline', 'character', 'debug', 'spellcap', 'special', 'tablinefill', 'spellrare', 'label', 'statuslinenc', 'adabegin', 'storageclass', 'specialcomment', 'markdowncode', 'netrwexe', 'adaend', 'conid', 'linehighlight', 'spellbad', 'netrwdir', 'specialchar', 'boolean', 'comment', 'conditional', 'constant', 'cursor', 'cursorlinenr', 'cursorline', 'delimiter', 'diffadd', 'diffchange', 'diffdelete', 'difftext', 'directory', 'error', 'errormsg', 'exception', 'float', 'foldcolumn', 'folded', 'function', 'identifier', 'ignore', 'incsearch', 'include', 'keyword', 'linenr', 'matchparen', 'modemsg', 'moremsg', 'nontext', 'normal', 'statuslinefile', 'statuslinenormmode', 'number', 'operator', 'pmenu', 'pmenusbar', 'pmenusel', 'pmenuthumb', 'preproc', 'question', 'repeat', 'search', 'specialkey', 'statement', 'statusline', 'string', 'structure', 'tablinesel', 'title', 'todo', 'type', 'underlined', 'vertsplit', 'visual', 'visualnos', 'warningmsg', 'wildmenu', 'gitgutteradd', 'gitgutterchange', 'gitgutterdelete', 'gitgutterchangedelete'] +let s:DefinedColors=['precondit', 'tag', 'define', 'mkdlink', 'typedef', 'vimwikilink', 'signcolumn', 'macro', 'spelllocal', 'tabline', 'character', 'debug', 'spellcap', 'special', 'tablinefill', 'spellrare', 'label', 'statuslinenc', 'adabegin', 'storageclass', 'specialcomment', 'markdowncode', 'netrwexe', 'adaend', 'conid', 'linehighlight', 'spellbad', 'netrwdir', 'specialchar', 'boolean', 'comment', 'conditional', 'constant', 'cursor', 'cursorlinenr', 'cursorline', 'delimiter', 'diffadd', 'diffchange', 'diffdelete', 'difftext', 'directory', 'error', 'errormsg', 'exception', 'float', 'foldcolumn', 'folded', 'function', 'identifier', 'ignore', 'incsearch', 'include', 'keyword', 'linenr', 'matchparen', 'modemsg', 'moremsg', 'nontext', 'normal', 'statuslinefile', 'statuslinenormmode', 'number', 'operator', 'pmenu', 'pmenusbar', 'pmenusel', 'pmenuthumb', 'preproc', 'question', 'repeat', 'search', 'specialkey', 'statement', 'statusline', 'string', 'structure', 'tablinesel', 'title', 'todo', 'type', 'underlined', 'vertsplit', 'visual', 'visualnos', 'warningmsg', 'wildmenu', 'gitgutteradd', 'gitgutterchange', 'gitgutterdelete', 'gitgutterchangedelete', 'normalfloat'] function! s:ClearUndefinedColors(colors) let undefined_groups = filter(a:colors->keys()->map('tolower(v:val)'), 'index(s:DefinedColors, tolower(v:val)) < 0') call map(undefined_groups, "execute('highlight' . ' ' . v:val . ' ' . 'NONE')") diff --git a/vim/idea.vimrc b/vim/idea.vimrc @@ -1,58 +0,0 @@ -" Settings -set number -set showmode -set ignorecase -set hlsearch -set incsearch -set smartcase -set surround - -" Commands -command! ListFileTypes echo glob($VIMRUNTIME . '/syntax/*.vim') -command! CDC cd %:p:h -command! Maketab set noet ts=2 | %retab! -command! Diff w !diff % - -command! Diffc w !git diff % - -command! Fuckwindows %s/ //g - -" Abbreviations -cnoreabbrev W! w! -cnoreabbrev Q! q! -cnoreabbrev Qall! qall! -cnoreabbrev Wq wq -cnoreabbrev Wa wa -cnoreabbrev wQ wq -cnoreabbrev WQ wq -cnoreabbrev W w -cnoreabbrev Q q -cnoreabbrev Qall qall -cnoreabbrev E Explore -cnoreabbrev Colors XtermColorTable - -" Mappings -let mapleader="," - -" Command mode -cnoremap w!! w !sudo tee > /dev/null % - -" Normal mode -nnoremap ; : -nnoremap q: <Nop> -nnoremap <leader>dif :Diff<cr> -nnoremap <leader>/ :noh<cr> -nnoremap <leader>b :ls<cr>:b<Space> -nnoremap U :syntax sync fromstart<cr>:redraw!<cr> -nnoremap <leader>qq mzggg?G`z -nnoremap zh mzzt10<c-u>`z -nnoremap <leader>dh :DeleteHiddenBuffers<cr> -nnoremap <leader>s :b#<cr> -nnoremap <leader>hs :set list!<cr> -nnoremap <leader>mm :<C-u>marks<CR>:normal! ` -nnoremap <leader>ml :<C-u>marks a-z<CR>:normal! ` -nnoremap <expr> <silent> 0 col('.') == match(getline('.'),'\S')+1 ? '0' : '^' - -" Visual mode -vnoremap < <gv -vnoremap > >gv -vnoremap J :m '>+1<cr>gv=gv -vnoremap K :m '<-2<cr>gv=gv diff --git a/vim/plugin/searchfold.vim b/vim/plugin/searchfold.vim @@ -0,0 +1,2 @@ +command! SearchFold call searchfold#Toggle() +nnoremap <Plug>SearchFold :<c-u>SearchFold<CR> diff --git a/vim/plugin/sessions.vim b/vim/plugin/sessions.vim @@ -1,10 +0,0 @@ -if exists("g:loaded_sessions") || &cp - finish -endif - -let g:loaded_sessions = 1 - -noremap <silent> <unique> <script> <Plug>SaveSession :call sessions#SaveSession()<CR> -noremap <silent> <unique> <script> <Plug>LoadSession :call sessions#LoadSession()<CR> -noremap <silent> <unique> <script> <Plug>DeleteSession :call sessions#DeleteSession()<CR> -noremap <silent> <unique> <script> <Plug>CloseSession :call sessions#CloseSession()<CR> diff --git a/vim/snippets/bib.snippets b/vim/snippets/bib.snippets @@ -0,0 +1,167 @@ +# https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management +snippet article An article from a magazine or a journal. + @article{${1:Xarticle}, + author = {}, + title = {}, + journal = {}, + ?_volume = {}, + ?_number = {}, + ?_pages = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet book A published book + @book{${1:Xbook}, + author = {}, + title = {}, + publisher = {}, + ?_volume = {}, + ?_number = {}, + ?_series = {}, + ?_address = {}, + ?_edition = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet booklet A bound work without a named publisher or sponsor. + @booklet{${1:Xbooklet}, + ?_author = {}, + title = {}, + ?_howpublished = {}, + ?_address = {}, + ?_year = {}, + ?_month = {}, + ?_note = {}, + } +snippet inbook A section of a book without its own title. + @inbook{${1:Xinbook}, + author = {}, + editor = {}, + title = {}, + chapter = {}, + pages = {}, + publisher= {}, + ?_volume = {}, + ?_number = {}, + ?_series = {}, + ?_type = {}, + ?_address= {}, + ?_edition= {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet incollection A section of a book having its own title. + @incollection{${1:Xincollection}, + author = {}, + title = {}, + booktitle= {}, + publisher= {}, + ?_editor = {}, + ?_volume = {}, + ?_number = {}, + ?_series = {}, + ?_type = {}, + ?_chapter= {}, + ?_pages = {}, + ?_address= {}, + ?_edition= {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet inproceedings An article in a conference proceedings. + @inproceedings{${1:Xinproceedings}, + author = {}, + title = {}, + booktitle = {}, + ?_editor = {}, + ?_volume = {}, + ?_number = {}, + ?_series = {}, + ?_pages = {}, + ?_address = {}, + ?_organization = {}, + ?_publisher = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet manual Technical manual + @manual{${1:Xmanual}, + title = {}, + ?_author = {}, + ?_organization = {}, + ?_address = {}, + ?_edition = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet mastersthesis Master's thesis + @mastersthesis{${1:Xthesis}, + author = {}, + title = {}, + school = {}, + ?_type = "diploma thesis", + ?_address = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet misc Template useful for other kinds of publication + @misc{${1:Xmisc}, + ?_author = {}, + ?_title = {}, + ?_howpublished = {}, + ?_year = {}, + ?_month = {}, + ?_note = {}, + } +snippet phdthesis Ph.D. thesis + @phdthesis{${1:Xphdthesis}, + author = {}, + title = {}, + school = {}, + ?_address = {}, + year = {}, + ?_month = {}, + ?_keywords = {}, + ?_note = {}, + } +snippet proceedings The proceedings of a conference. + @proceedings{${1:Xproceedings}, + title = {}, + ?_editor = {}, + ?_volume = {}, + ?_number = {}, + ?_series = {}, + ?_address = {}, + ?_organization = {}, + ?_publisher = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet techreport Technical report from educational, commercial or standardization institution. + @techreport{${1:Xtreport}, + author = {}, + title = {}, + institution = {}, + ?_type = {}, + ?_number = {}, + ?_address = {}, + year = {}, + ?_month = {}, + ?_note = {}, + } +snippet unpublished An unpublished article, book, thesis, etc. + @unpublished{${1:Xunpublished}, + author = {}, + title = {}, + ?_year = {}, + ?_month = {}, + note = {}, + } diff --git a/vim/snippets/tex.snippets b/vim/snippets/tex.snippets @@ -0,0 +1,105 @@ +snippet pre typewriter (monospace) text + \\texttt{${1:text}}${0} +snippet it italic text + \\textit{${1:text}}${0} +snippet b bold face text + \\textbf{${1:text}}${0} +snippet under underline text + \\underline{${1:text}}${0} +snippet over overline text + \\overline{${1:text}}${0} +snippet emp emphasize text + \\emph{${1:text}}${0} +snippet sc small caps text + \\textsc{${1:text}}${0} +snippet fig figure + \\begin{figure}[tb] + \\centering + \\includegraphics[width=${1:\\linewidth}]{${2:filename}} + \\caption{${3:caption}} + \\label{fig:${4:label}} + \\end{figure} + ${0} +snippet todo TODO + \\TODO{$1}$0 +snippet nc \newcommand + \\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} + +# Section +snippet sec \section + \\section{${1:section name}} + \\label{sec:${2:$1}} + ${0} +# Section without number +snippet sec* \section* + \\section*{${1:section name}} + \\label{sec:${2:$1}} + ${0} +# Sub Section +snippet sub \subsection + \\subsection{${1:subsection name}} + \\label{sub:${2:$1}} + ${0} +# Sub Section without number +snippet sub* \subsection* + \\subsection*{${1:subsection name}} + \\label{sub:${2:$1}} + ${0} +# Sub Sub Section +snippet ssub \subsubsection + \\subsubsection{${1:subsubsection name}} + \\label{ssub:${2:$1}} + ${0} +# Sub Sub Section without number +snippet ssub* \subsubsection* + \\subsubsection*{${1:subsubsection name}} + \\label{ssub:${2:$1}} + ${0} +# Paragraph +snippet par \paragraph + \\paragraph{${1:paragraph name}} + \\label{par:${2:$1}} + ${0} +# Sub Paragraph +snippet subp \subparagraph + \\subparagraph{${1:subparagraph name}} + \\label{subp:${2:$1}} + ${0} + +snippet enum enumerate environment + \\begin{enumerate} + \\item ${0} + \\end{enumerate} +snippet enuma enumerate environment + \\begin{enumerate}[(a)] + \\item ${0} + \\end{enumerate} +snippet enumi enumerate environment + \\begin{enumerate}[(i)] + \\item ${0} + \\end{enumerate} +# Itemize +snippet item itemize environment + \\begin{itemize} + \\item ${0} + \\end{itemize} +snippet it \item + \\item ${1:${VISUAL}} +# Description +snippet desc description environment + \\begin{description} + \\item[${1}] ${0} + \\end{description} +# Endless new item +snippet ]i \item (recursive) + \\item ${1} + ${0:]i} + +# Code listings +snippet lst Code listing + \\begin{lstlisting}[float=tb,caption={${1}}, label={code:${2}}, language=${3}] + ${0} + \\end{lstlisting} +snippet lsi + \\lstinline|${1}| ${0} + diff --git a/vim/snippets/vim.snippets b/vim/snippets/vim.snippets @@ -0,0 +1,13 @@ +snippet undo_ftplugin Undo an ftplugin config + let b:undo_ftplugin = (exists('b:undo_ftplugin') ? b:undo_ftplugin.'|' : '') + let b:undo_ftplugin .= '${1:changes to make}' + +snippet compiler Compiler boilerplate + if exists("current_compiler") + finish + endif + let current_compiler = "${1:compiler name}" + if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal <args> + endif + CompilerSet makeprg=$0 diff --git a/vim/spell/en.utf-8.add b/vim/spell/en.utf-8.add @@ -644,3 +644,12 @@ OllyDbg Searx Homebrew microservices +IHEX +Bincopy +Bgrep +MPU +FirmXRay's +PMIO +DBMSSL +ADR +CDMI diff --git a/vim/spell/en.utf-8.add.spl b/vim/spell/en.utf-8.add.spl Binary files differ. diff --git a/vim/ultisnips/java.snippets b/vim/ultisnips/java.snippets @@ -0,0 +1,3 @@ +snippet sout "System.out.println" w +System.out.println($1);$0 +endsnippet diff --git a/vim/vimrc b/vim/vimrc @@ -1,6 +1,5 @@ " vim: foldmethod=marker foldlevel=0 let mapleader=" " " Set the mapleader to be space -let maplocalleader=" " " Plugins {{{1 " Installation {{{2 @@ -145,6 +144,13 @@ Plug 'rust-lang/rust.vim', { 'for': 'rust' } " Show context Plug 'wellle/context.vim' +" Fuzzy finder in vim +Plug 'junegunn/fzf', { 'dir': '$HOME/.dotfiles/tools/fzf', 'do': './install --all --xdg --no-fish'} +Plug 'junegunn/fzf.vim' + +" Additional text objects +Plug 'wellle/targets.vim' + " Vim-only if !has('nvim') " Substitute preview @@ -160,14 +166,7 @@ if !has('nvim') " Simple commenting Plug 'tpope/vim-commentary' - " Fuzzy finder in vim - Plug 'junegunn/fzf', { 'dir': '$HOME/.dotfiles/tools/fzf', 'do': './install --all --xdg --no-fish'} - Plug 'junegunn/fzf.vim' - endif - -" Snippets -Plug 'SirVer/ultisnips' call plug#end() " quickfix filtering @@ -180,6 +179,12 @@ endif " }}}2 " Config {{{2 +" Say {{{3 +let g:say_wpm = 230 +nmap gs <Plug>Say +vmap gs <Plug>Say +nmap gsl <Plug>SayLine +nmap gss <Plug>SayBuffer " Tagbar {{{3 " Maps nnoremap <leader>tt :TagbarToggle<CR> @@ -261,9 +266,29 @@ let g:doge_mapping = '<leader>gd' let g:goyo_width = "80%" let g:goyo_height = "85%" " Vimtex {{{3 +let g:vimtex_view_automatic=0 +let g:vimtex_quickfix_open_on_warning = 0 +let g:vimtex_quickfix_ignore_filters = [ '[Ww]arning', '\(Under\|Over\)full', 'Missing ".* in' ] let g:tex_flavor='latex' +let g:vimtex_toc_config = { + \ 'todo_sorted': 0, + \ 'show_help': 0 + \ } let g:vimtex_view_method='sioyek' let g:vimtex_view_sioyek_exe='/Applications/sioyek.app/Contents/MacOS/sioyek' +let g:vimtex_syntax_custom_cmds = [ + \ {'name': 'fullref', 'argspell': 0}, + \ {'name': 'citea', 'argspell': 0}, + \ {'name': 'citen', 'argspell': 0, 'arggreedy': 1}, + \ {'name': 'citet', 'argspell': 0, 'arggreedy': 1} + \ ] +let g:vimtex_complete_ref = { + \ 'custom_patterns': ['\\fullref\*\?{[^}]*'] + \ } +let g:vimtex_complete_bib = { + \ 'custom_patterns': ['\\citen\*\?{[^}]*}{[^}]*', + \ '\\citea\*\?{[^}]*'] + \ } let g:tex_comment_nospell=1 let g:vimtex_syntax_nospell_comments=1 let g:vimtex_quickfix_mode=0 @@ -291,71 +316,52 @@ let g:vimtex_compiler_tectonic = { \ '--keep-intermediates' \ ], \} -" Ultisnips {{{3 -let g:UltiSnipsExpandTrigger = '<tab>' -let g:UltiSnipsJumpForwardTrigger = '<tab>' -let g:UltiSnipsJumpBackwardTrigger = '<s-tab>' -let g:UltiSnipsSnippetDirectories = ['~/.dotfiles/vim/ultisnips'] -let g:UltiSnipsEditSplit = "vertical" -cabbrev USE UltiSnipsEdit -" Complete ultisnips with <C-x><C-u>, which is coincidentally the same mapping as user completion -" (custom function btw) -set completefunc=ultisnips_complete#ListSnippets - -" NOTE: performance improvement. autotrigger leads to slow typing in markdown -" mode. -augroup ultisnips_no_auto_expansion - au! - au VimEnter * au! UltiSnips_AutoTrigger -augroup END " Abolish {{{3 " Work with variants of words easily -let g:abolish_save_file = '"$HOME"/.dotfiles/vim/abolish_save_file.vim' +let g:abolish_save_file = $HOME.."/.dotfiles/vim/abolish_save_file.vim" " Fzf {{{3 -if exists('g:loaded_fzf') - set rtp+="$HOME"/.dotfiles/tools/fzf - function! s:build_quickfix_list(lines) - call setqflist(map(copy(a:lines), '{ "filename": v:val }')) - copen - cc - endfunction - let g:fzf_action = { - \ 'ctrl-f': function('s:build_quickfix_list'), - \ 'ctrl-t': 'tabedit', - \ 'ctrl-p': 'split', - \ 'ctrl-v': 'vsplit' } - let g:fzf_layout = {'window': { 'width': 0.9, 'height': 0.4 } } - let g:fzf_preview_window = 'right:60%' - " Jump to existing buffer/window if possible - let g:fzf_buffers_jump = 1 - - nnoremap <leader>F :Files<CR> - nnoremap <leader><c-f><c-f> :Files<space> - nnoremap <expr> <leader><c-f>. ":Files " .. expand("%:h") .. "<CR>" - nnoremap <leader>B :Buffers<CR> - nnoremap <leader>G :Lines<CR> - nnoremap <leader>W :BLines<CR> - nnoremap <expr> <leader>Z ':BLines '..&foldmarker->split(',')[0]..'<CR>' - nnoremap <leader>? :Helptags<CR> - nnoremap <leader>T :Tags<CR> - nnoremap <leader>/ :Ag<CR> - nnoremap <leader>M :Marks<CR> - nnoremap <leader>; :History:<CR> - - " My extensions - nmap <leader>J <Plug>FzfChangesJumpsJumps - nmap <leader>C <Plug>FzfChangesJumpsChanges - - " Search for Todos/Fixmes - command! Todo Ag ((TO ?DO)|FIXME):<space> - nnoremap <leader>! :Todo<CR> - - " Set a filetype - cabbrev setf Filetypes - - command! Scripts call fzf#run(fzf#wrap({'source': 'command find "$(readlink ~/.scripts)" -type f -or -type l -not -ipath "*/.git/*"', 'options': '--multi --reverse --inline-info --prompt="scripts> "', 'sink': 'sp'})) - command! Configs call fzf#run(fzf#wrap({'source': 'command find ~/.dotfiles -type f ! -ipath "*/.git/*" ! -ipath "*/bin/*" ! -ipath "*/oh-my-zsh/*" ! -name ".DS_Store"', 'options': '--multi --reverse --inline-info --prompt="configs> "', 'sink': 'sp'})) -endif +set rtp+="$HOME"/.dotfiles/tools/fzf +function! s:build_quickfix_list(lines) + call setqflist(map(copy(a:lines), '{ "filename": v:val }')) + copen + cc +endfunction +let g:fzf_action = { + \ 'ctrl-f': function('s:build_quickfix_list'), + \ 'ctrl-t': 'tabedit', + \ 'ctrl-p': 'split', + \ 'ctrl-v': 'vsplit' } +let g:fzf_layout = {'window': { 'width': 0.9, 'height': 0.4 } } +let g:fzf_preview_window = 'right:60%' +" Jump to existing buffer/window if possible +let g:fzf_buffers_jump = 1 + +nnoremap <leader>F :Files<CR> +nnoremap <leader><c-f><c-f> :Files<space> +nnoremap <expr> <leader><c-f>. ":Files " .. expand("%:h") .. "<CR>" +nnoremap <leader>B :Buffers<CR> +nnoremap <leader>G :Lines<CR> +nnoremap <leader>W :BLines<CR> +nnoremap <expr> <leader>Z ':BLines '..&foldmarker->split(',')[0]..'<CR>' +nnoremap <leader>? :Helptags<CR> +nnoremap <leader>T :Tags<CR> +nnoremap <leader>/ :Ag<CR> +nnoremap <leader>M :Marks<CR> +nnoremap <leader>; :History:<CR> + +" My extensions +nmap <leader>J <Plug>FzfChangesJumpsJumps +nmap <leader>C <Plug>FzfChangesJumpsChanges + +" Search for Todos/Fixmes +command! Todo Ag ((TO ?DO)|FIXME):<space> +nnoremap <leader>! :Todo<CR> + +" Set a filetype +cabbrev setf Filetypes + +command! Scripts call fzf#run(fzf#wrap({'source': 'command find "$(readlink ~/.scripts)" -type f -or -type l -not -ipath "*/.git/*"', 'options': '--multi --reverse --inline-info --prompt="scripts> "', 'sink': 'sp'})) +command! Configs call fzf#run(fzf#wrap({'source': 'command find ~/.dotfiles -type f ! -ipath "*/.git/*" ! -ipath "*/bin/*" ! -ipath "*/oh-my-zsh/*" ! -name ".DS_Store"', 'options': '--multi --reverse --inline-info --prompt="configs> "', 'sink': 'sp'})) " Vimwiki {{{3 let tlist_vimwiki_settings = 'wiki;h:Headers' let g:vimwiki_table_mappings = 0 " avoid vimwiki conflict with Ultisnips @@ -373,11 +379,6 @@ let g:vimwiki_ext2syntax = {'.wiki': 'default'} nnoremap <leader>wc :VimwikiCheckLinks<CR> nmap <leader>ww <Plug>VimwikiIndex -" Sessions {{{3 -nmap <leader>ss <Plug>SaveSession -nmap <leader>sl <Plug>LoadSession -nmap <leader>sd <Plug>DeleteSession -nmap <leader>sq <Plug>CloseSession " Haskell {{{3 let hs_highlight_delimiters = 1 let hs_highlight_boolean = 1 @@ -971,6 +972,10 @@ nnoremap gV `[v`] " Save in insert mode inoremap <C-Z> <C-o>:w<CR> +" Allow undo/redo on C-w and C-u in insert mode +inoremap <c-u> <c-g>u<c-u> +inoremap <c-w> <c-g>u<c-w> + if !has('nvim') " Config edit mappings " Why :drop? It uses the file if it's already open. @@ -1007,12 +1012,6 @@ nnoremap Y y$ nnoremap <leader>o m`o<esc>`` nnoremap <leader>O m`O<esc>`` -" Custom session maps -nnoremap <leader>ss :call sessions#SaveSession()<CR> -nnoremap <leader>sl :call sessions#LoadSession()<CR> -nnoremap <leader>sd :call sessions#DeleteSession()<CR> -nnoremap <leader>sq :call sessions#CloseSession()<CR> - " native file browsing nnoremap <leader>f :Lexplore<CR> @@ -1104,6 +1103,7 @@ nnoremap <leader>z{ :setlocal foldmethod=marker<CR> nnoremap <leader>zs :setlocal foldmethod=syntax<CR> nnoremap <leader>ze :setlocal foldmethod=expr<CR> nnoremap <leader>zd :setlocal foldmethod=diff<CR> +nmap z/ <Plug>SearchFold " Set the foldlevel nnoremap <leader>zn :set foldlevel= @@ -1122,7 +1122,6 @@ nnoremap <leader>lp :lprevious<CR> nnoremap <leader>lb :lbefore<CR> nnoremap <leader>la :lafter<CR> nnoremap <leader>lf :lfirst<CR> - " Autocommands {{{1 if has('autocmd') augroup vimrc_sets