summaryrefslogtreecommitdiffstats
path: root/vim/vimrc
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2023-09-26 08:37:44 +0100
committerMatthew Lemon <y@yulqen.org>2023-09-26 08:37:44 +0100
commit70df4b2bcbfe7c6392c7cbbd01cf06d95dc47a31 (patch)
treef8b1ee84e6dc7793215211588a7057eeff586f3d /vim/vimrc
parent857557b5694cb07aaff7ce804d26f7c0440a3bff (diff)
Brings vim into line with Arch
Diffstat (limited to 'vim/vimrc')
-rw-r--r--vim/vimrc264
1 files changed, 143 insertions, 121 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 41d605a..17b2187 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,14 +1,64 @@
filetype plugin on
filetype indent on
syntax on
-
-" leader
+runtime macros/matchit.vim "allows jumping between brackets with % in normal mode
+" }}}
+" Leaders {{{
let maplocalleader = "\\"
let mapleader = ","
+nnoremap <leader>q :call TaskWarriorAddCurrentLine()<CR>
+" pandoc command to generate weekly plan page in Firefox (or not, if we just
+" wish to refresh)
+nnoremap <leader>w :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html; firefox /tmp/toss.html &<cr>
+nnoremap <leader>W :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html<cr>
+" Open vimrc
+nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $HOME/.vim/vimrc<cr>
+" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS).
+if (exists("*strftime"))
+ noremap <silent> <leader>date "=strftime("%F")<CR>p9h
+ noremap <silent> <leader>time "=strftime("%X")<CR>p7h
+endif
-set nocompatible
+" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS).
+if (exists("*strftime"))
+ noremap <silent> <leader>date "=strftime("%F")<CR>p9h
+ noremap <silent> <leader>time "=strftime("%X")<CR>p7h
+endif
+" Generate ctags for current working directory
+nnoremap <leader>tt :silent !ctags -R . <CR>:redraw!<CR>
+" notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/
+" Go to index of notes and set working directory to my notes
+nnoremap <leader>ni :e $NOTES_DIR/index.md<CR>:cd $NOTES_DIR<CR>
+" related to https://oleksii.shmalko.com/2014/using-vim-as-c-cpp-ide/
+" to enable putting a config file in the proejct directory
+" clear search highlights
+nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
+nnoremap <leader><C-p> :<C-u>FZF!<CR>
+nnoremap <leader>t :Files<CR>
+nnoremap <leader>o :Tags<CR>
+nnoremap <leader>h :History<CR>
+nnoremap <silent> <leader>0 :Files<CR>
+nnoremap <silent> <leader>; :BLines<CR>
+nnoremap <silent> <leader>l :Lines<CR>
+nnoremap <silent> <leader>o :BTags<CR>
+nnoremap <silent> <leader>b :Buffers<CR>
+nnoremap <silent> <leader>? :History:<CR>
+nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR>
+nnoremap <silent> <leader>ft :Filetypes<CR>
+nnoremap <silent> <leader>CC :Commands<CR>
+" Open quickfix list in a right vertical split (good for Ngrep results)
+command! Vlist botright vertical copen | vertical resize 50
+nnoremap <leader>v : Vlist<CR>
+" }}}
+" Options {{{
+set autoread
+set exrc
+set secure
set scrolloff=1
set history=799
+set encoding=utf-8
+set wrap
+set wrapmargin=0
set wildignore=**/__pycache*/**
set wildoptions=pum
set wildmenu
@@ -35,17 +85,18 @@ set path+=**
set relativenumber
set number
set more
-set signcolumn=yes
+set signcolumn=number
set colorcolumn=0
set equalalways
set showmode
-set listchars=tab:»→,trail:␣
+set nolist
+set listchars=tab:»-,trail:␣,leadmultispace:---+,eol:\\U000021b5
set shortmess+=c
set tags+=./tags
set background=dark
set completeopt=menuone,longest
-
-" Function to allow adding a line of text to taskwarrior
+" }}}
+" Function to allow adding a line of text to taskwarrior {{{
function! TaskWarriorAddCurrentLine()
let current_line = getline('.')
silent execute ":!task add " . shellescape(current_line)
@@ -53,58 +104,36 @@ function! TaskWarriorAddCurrentLine()
echo "Task added: " . current_line
delete
endfunction
-
-nnoremap <leader>q :call TaskWarriorAddCurrentLine()<CR>
-
-" colorscheme goes here, outside source control
-source ~/.vim/ephemera.vim
-highlight SignColumn guibg=blue ctermbg=black
-
-" macro to go to end of sentence and add a line break (for
-" one-line-per-sentence vimming...)
-let @s = ")i\<BS>\<CR>\<Esc>"
-
-" i don't bother with folding, but it's here if i need it.
+" }}}
+" Folding {{{
if has('folding')
set foldmethod=marker
- set foldmarker=#\ {{{,#\ }}}
+" set foldmarker=#\ {{{,#\ }}}
set viewoptions=folds,options,cursor,unix,slash
endif
-
" disable folding by default with vim-markdown
let g:vim_markdown_folding_disabled = 1
-
-" Open vimrc
-nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $HOME/.vim/vimrc<cr>
-
-" Jump up or down by 10 lines.
+" }}}
+" Remaps {{{
noremap <silent> J 10j
noremap <silent> K 10k
-
-" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS).
-if (exists("*strftime"))
- noremap <silent> <leader>date "=strftime("%F")<CR>p9h
- noremap <silent> <leader>time "=strftime("%X")<CR>p7h
-endif
-
-" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS).
-if (exists("*strftime"))
- noremap <silent> <leader>date "=strftime("%F")<CR>p9h
- noremap <silent> <leader>time "=strftime("%X")<CR>p7h
-endif
-
-"keymap for Fern
-nnoremap ;f :Fern . -drawer<cr>
-
+" macro to go to end of sentence and add a line break (for
+" one-line-per-sentence vimming...)
+let @s = ")i\<BS>\<CR>\<Esc>"
+" remap :W to :w - :W was previous Windows in fzf
+command! W w
+" }}}
+" Plugins {{{
call plug#begin()
"Plug 'vim-scripts/AutoComplPop'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
-Plug 'ycm-core/YouCompleteMe'
+Plug 'ayu-theme/ayu-vim'
Plug 'airblade/vim-tailwind'
-Plug 'lambdalisue/fern.vim'
+Plug 'morhetz/gruvbox'
+Plug 'eemed/sitruuna.vim'
Plug 'junegunn/goyo.vim'
-Plug 'sheerun/vim-polyglot'
+" Plug 'sheerun/vim-polyglot'
Plug 'preservim/vim-markdown'
Plug 'mhinz/vim-signify'
Plug 'vim-test/vim-test'
@@ -118,9 +147,10 @@ Plug 'tpope/vim-fugitive'
Plug 'SirVer/UltiSnips'
Plug 'honza/vim-snippets'
Plug 'dense-analysis/ale'
+Plug 'tomasiser/vim-code-dark'
call plug#end()
-
-" vim-tailwind
+" }}}
+" vim-tailwind {{{
function! s:is_tailwind()
return !empty(findfile('tailwind.config.js', '.;')) ||
\ !empty(findfile('theme/static_src/tailwind.config.js', '.;'))
@@ -131,34 +161,12 @@ nmap <silent> <buffer> gk <Plug>(tailwind-lookup)
autocmd BufEnter *.html,*.slim if s:is_tailwind() |
\ setlocal omnifunc=tailwind#Complete |
\ endif
-
-" YCM
-nnoremap <silent> <localleader>h <Plug>(YCMToggleInlayHints)
-nnoremap gd :YcmCompleter GoToDefinition<CR>
-nnoremap <leader>gr :YcmCompleter GoToReferences<CR>
-nnoremap K :YcmCompleter GetDoc<CR>
-" this will disable tab, allowing it to be used for ultisnips
-let g:ycm_enable_inlay_hints = 0
-let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
-let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
-let g:ycm_python_interpreter_path = '.venv/bin/python3'
-let g:ycm_auto_trigger = 0
-let g:ycm_python_sys_path = []
-let g:ycm_show_diagnostics_ui = 1
-let g:ycm_extra_conf_vim_data = [
- \ 'g:ycm_python_interpreter_path',
- \ 'g:ycm_python_sys_path'
- \]
-"let g:ycm_global_ycm_extra_conf = '~/.global_extra_conf.py'
-nnoremap <leader>jd :YcmCompleter GoTo<CR>
-imap <silent> <C-l> <Plug>(YCMToggleSignatureHelp)'.
-
-
-" ALE ale config
+" }}}
+" ALE {{{
let g:ale_enabled = 1
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
-let g:ale_sign_error = '✘'
-let g:ale_sign_warning = '⚠'
+let g:ale_sign_error = '!'
+let g:ale_sign_warning = '?'
let g:ale_lint_on_text_changed = 0
let g:ale_hover_cursor = 0
let g:ale_virtualtext_cursor = 'disabled'
@@ -167,22 +175,26 @@ let g:ale_open_list = 0
let g:ale_set_highlights = 1
let g:ale_set_signs = 1
let g:ale_set_loclist = 1
-let g:ale_set_quickfix = 0
+let g:ale_set_quickfix = 1
let g:ale_echo_cursor = 1
-let g:ale_echo_msg_error_str = 'Error'
-let g:ale_echo_msg_format = '%linter% - %code: %%s'
-let g:ale_loclist_msg_format = '%linter% - %code: %%s'
-let g:ale_echo_msg_warning_str = 'Warning'
+let g:ale_echo_msg_error_str = 'ALE Error'
+let g:ale_echo_msg_format = 'ALE: %linter% - %code: %%s'
+let g:ale_loclist_msg_format = 'ALE: %linter% - %code: %%s'
+let g:ale_echo_msg_warning_str = 'ALE Warning'
let g:ale_linters = {'python': ['pyright', 'flake8', 'mypy'],
\ 'ocaml': ['merlin'],
-\ 'cpp': ['clang'],
+\ 'javascript': ['eslint'],
+\ 'cpp': ['clangd'],
\ 'yaml': ['yamllint'],
-\ 'c': ['clang'],
+\ 'c': ['clangd'],
\ 'go': ['gopls', 'golint', 'gofmt'],
\}
let g:ale_fixers = {
\ 'python': ['autoimport', 'isort', 'yapf', 'black'],
+\ 'javascript': ['eslint'],
\ 'go': ['gofmt'],
+\ 'cpp': ['clang-format'],
+\ 'c': ['clang-format'],
\ 'rust': ['rustfmt']
\ }
let g:ale_python_mypy_ignore_invalid_syntax = 1
@@ -192,8 +204,8 @@ let g:ale_python_mypy_options = '--config-file mypy.ini'
let g:ale_fix_on_save = 1
let g:ale_linters_explicit = 0
set omnifunc=ale#completion#OmniFunc
-
-" Make :grep use ripgrep
+" }}}
+" :grep use ripgrep {{{
if executable('rg')
set grepprg=rg\ --color=never\ --vimgrep
endif
@@ -207,46 +219,35 @@ command! -bang -nargs=* Rg
\ <bang>0)
nnoremap <C-p>a :Rg
-
-" Generate ctags for current working directory
-nnoremap <leader>tt :silent !ctags -R . <CR>:redraw!<CR>
-
-" notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/
-" Go to index of notes and set working directory to my notes
-nnoremap <leader>ni :e $NOTES_DIR/index.md<CR>:cd $NOTES_DIR<CR>
-
-" 'Notes Grep' with ripgrep (see grepprg)
+" }}}
+" 'Notes Grep' with ripgrep (see grepprg) {{{
" -i case insensitive
" -g glob pattern
" ! to not immediately open first search result
"command! -nargs=1 Ngrep :silent grep! "<args>" -i -g '*.md' $NOTES_DIR | execute ':redraw!'
command! -nargs=1 Ngrep vimgrep "<args>" $NOTES_DIR/**/*.md
nnoremap <leader>nn :Ngrep
-
-" Open quickfix list in a right vertical split (good for Ngrep results)
-command! Vlist botright vertical copen | vertical resize 50
-nnoremap <leader>v : Vlist<CR>
-
-" vim-test
+" }}}
+" vim-test {{{
nmap <silent> tn :TestNearest<CR>
nmap <silent> tf :TestFile<CR>
nmap <silent> ts :TestSuite<CR>
nmap <silent> tl :TestLast<CR>
nmap <silent> <leader>tv :TestVisit<CR>
let test#strategy = "basic"
-let test#python#pytest#options = '-q -s -n2'
+let test#python#pytest#options = '-q -s'
let test#python#runner = 'pytest'
let test#vimterminal#term_position = "belowright"
-
-" clear search highlights
-nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
-
-runtime macros/matchit.vim "allows jumping between brackets with % in normal mode
-
-" remap :W to :w - :W was previous Windows in fzf
-command! W w
-
-" FZF
+" }}}
+" Titbits {{{
+" " Increment an ordered (numbered) list with <leader><cr>
+" inoremap <leader><cr> <esc>yyp<C-a>
+" " sudo write
+" command! S :w !sudo tee %
+
+nnoremap <Tab> %
+" }}}
+" FZF {{{
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
@@ -275,18 +276,39 @@ let g:fzf_colors =
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
nnoremap <C-s> :GFiles!<CR>
- nnoremap <leader><C-p> :<C-u>FZF!<CR>
- nnoremap <leader>t :Files<CR>
- nnoremap <leader>o :Tags<CR>
- nnoremap <leader>h :History<CR>
- nnoremap <silent> <leader>0 :Files<CR>
- nnoremap <silent> <leader>; :BLines<CR>
- nnoremap <silent> <leader>l :Lines<CR>
- nnoremap <silent> <leader>o :BTags<CR>
- nnoremap <silent> <leader>b :Buffers<CR>
- nnoremap <silent> <leader>? :History:<CR>
- nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR>
- nnoremap <silent> <leader>ft :Filetypes<CR>
- nnoremap <silent> <leader>CC :Commands<CR>
imap <C-x><C-f> <plug>(fzf-complete-file-ag)
imap <C-x><C-l> <plug>(fzf-complete-line)
+" }}}
+" Colorscheme {{{
+" This is imported from the old ephemera.vim file which has now been removed
+"
+" I got the following from gruvbox docs
+"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
+"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
+"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
+if (has("nvim"))
+"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
+ let $NVIM_TUI_ENABLE_TRUE_COLOR=1
+endif
+"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
+"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
+" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
+if (has("termguicolors"))
+ set termguicolors
+endif
+
+"ayu theme
+" let ayucolor="light" " for light version of theme
+" let ayucolor="mirage" " for mirage version of theme
+let ayucolor="dark" " for dark version of theme
+
+"colorscheme gruber-darker
+let g:gruvbox_contrast_dark = "hard"
+let g:gruvbox_italicize_strings = 1
+let g:gruvbox_improved_strings = 1
+let g:gruvbox_improved_warnings = 1
+let g:gruvbox_invert_indent_guides = 1
+let g:gruvbox_invert_signs = 0
+" colorscheme ayu
+colorscheme sitruuna
+" }}}