Compare commits

..

6 Commits

Author SHA1 Message Date
df043515e4 Don't call coc#status() if it doesn't exist 2021-04-18 14:42:33 +01:00
5c3b9ee44b Use coc-jedi and coc-pyright instead of coc-pyls 2021-04-18 14:42:33 +01:00
c41626dc50 Add a call to coc#status() in statusline
Don't miss out on the status of coc.nvim by insuring updates are
rendered in the statusline.
2021-04-18 14:42:33 +01:00
99d793c4b0 Ignore compiled python files 2021-04-18 14:42:33 +01:00
559e9411e5 Fix coc.nvim mappings in C/C++ files 2021-04-18 14:42:33 +01:00
7c05e65929 Move formatexpr config in-tree, out of plugin
Introduces the `format` Python module which provides `clang_format()`
and `yapf()` functions which efficiently (compared to vimscript) invoke
`clang-format` or `yapf` respectively then apply the minimal number of
changes using `difflib.SequenceMatcher`.

Additionally, in order to invoke these Python functions add |autoload|
functions `format#clang_format()` and `format#yapf()` which can be
directly used by the 'formatexpr' setting.

Finally, add |ftplugin| files which set 'formatexpr' when the |autoload|
functions are available.
2021-04-18 14:42:33 +01:00
34 changed files with 89 additions and 284 deletions

9
.conduit.yaml Normal file
View File

@@ -0,0 +1,9 @@
---
- location: ~/.vim
- pip:
- vim-vint
- yamllint
- cmakelint
- repo:
- remote: https://github.com/k-takata/minpac.git
location: ~/.vim/pack/minpac/opt/minpac

View File

@@ -8,7 +8,7 @@ from argparse import ArgumentParser
def main():
parser = ArgumentParser()
$0
parser.add_argument('${0:argument}')
args = parser.parse_args()
@@ -16,7 +16,7 @@ if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit(130)
pass
endsnippet
snippet debug "Set ipdb breakpoint"

View File

@@ -45,7 +45,7 @@ if exists('g:c_doxygen') && g:c_doxygen
" Match: @param name description. @retval name description.
" ^^^^ ^^^^
syn region cDoxygenSpecial matchgroup=cDoxygenComment start='@\(param\(\[\(\|in\|out\|in,out\)\]\)\?\|retval\)\=\s\+' end='\(\s\|$\)' contained display
syn region cDoxygenSpecial matchgroup=cDoxygenComment start='@\(param\(\[\(\|in\|out\|in,out\)\]\)\|retval\)\=\s\+' end='\(\s\|$\)' contained display
" Match: @tparam name description.
" ^^^^

View File

@@ -1,4 +1,3 @@
hi link jsonKeyword Function
hi link jsonNull Constant
hi link jsonQuote Delimiter
setlocal conceallevel=0

View File

@@ -10,26 +10,12 @@ function! build#dir(...) abort
let l:dir = s:dirs[0]
unlet s:dirs
else
" Multiple build directories found, select one.
if exists('*popup_menu')
" Create popup menu to select the build directory. Callback to this
" function on completion, handled in the else branch below.
" Multiple build directories found, create popup menu to select one.
" Set the callback to this function on completion, handled below.
call popup_menu(s:dirs, #{
\ filter: 'popup_filter_menu',
\ callback: 'build#dir',
\ })
else
" Fallback to inputlist when popup_menu is not available.
let l:choices = []
let l:index = 1
for l:dir in s:dirs
call add(l:choices, string(l:index).': '.l:dir)
let l:index += 1
endfor
let l:index = inputlist(l:choices)
let l:dir = s:dirs[l:index - 1]
echomsg ' '.l:dir
endif
endif
else
if a:0 == 1
@@ -49,30 +35,17 @@ function! build#dir(...) abort
endif
endif
if exists('l:dir')
" Set build directory.
let l:cwd = substitute(getcwd(), '\\', '\/', 'g')
let $BUILD_DIR = l:cwd.'/'.substitute(l:dir, '\/$', '', '')
if executable('compdb')
" Post-process compile_commands.json with compdb, adds header files to
" missing compile_commands.json for more accurate diagnostics.
let l:database_dir = l:cwd.'/.vim'
let l:compile_commands = l:database_dir.'/compile_commands.json'
call systemlist('compdb -p '.$BUILD_DIR.' list > '.l:compile_commands)
else
let l:database_dir = $BUILD_DIR
endif
" Read/create .vim/coc-settings.json
" Set build directory and restart YouCompleteMe.
let $BUILD_DIR = getcwd().'/'.substitute(l:dir, '\/$', '', '')
let l:coc_settings = {}
if isdirectory('.vim')
let l:coc_settings = json_decode(join(readfile('.vim/coc-settings.json'), ''))
else
call mkdir('.vim')
endif
" Update .vim/coc-settings.json with new build directory.
let l:coc_settings['clangd.compilationDatabasePath'] = l:database_dir
let l:coc_settings['clangd.compilationDatabasePath'] = $BUILD_DIR
let l:coc_settings['cmake.lsp.buildDirectory'] = $BUILD_DIR
call writefile([json_encode(l:coc_settings)], '.vim/coc-settings.json')
" Finally restart coc.nvim with new config.
CocRestart
endif
endfunction

View File

@@ -16,6 +16,6 @@ function! tmux#isOption(option, value) abort
if !tmux#inSession()
return 0
endif
let l:option = trim(system('tmux show-options -g '.a:option))
return l:option ==# a:option.' '.a:value
let l:set_clipboard = trim(system('tmux show-options -g '.a:option))
return l:set_clipboard ==# 'set-clipboard '.a:value
endfunction

View File

@@ -1,3 +0,0 @@
function! wsl#isDetected() abort
return $WSLENV !=# ''
endfunction

View File

@@ -1,17 +1 @@
{
"clangd.inlayHints.enable": false,
"cmake.lsp.enable": true,
"diagnostic.enableHighlightLineNumber": false,
"diagnostic.errorSign": "▸",
"diagnostic.hintSign": "▸",
"diagnostic.infoSign": "▸",
"diagnostic.warningSign": "▸",
"powershell.integratedConsole.showOnStartup": false,
"suggest.noselect": true,
"yaml.schemas": {
"https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json": [
".gitlab-ci.yml",
".gitlab/ci/*.yml"
]
}
}
{"cmake.lsp.enable": true}

View File

@@ -126,9 +126,7 @@ if has('gui_running') || &t_Co == 256
call s:hi('SpellLocal', '5', '', '')
call s:hi('SpellRare', '3', '', '')
call s:hi('StatusLine', '15', '233', '')
call s:hi('StatusLineTerm', '15', '233', '')
call s:hi('StatusLineNC', '', '235', '')
call s:hi('StatusLineTermNC', '', '235', '')
call s:hi('TabLine', '246', '235', 'bold')
call s:hi('TabLineFill', '', '235', '')
call s:hi('TabLineSel', '248', '', 'bold')
@@ -187,10 +185,6 @@ if has('gui_running') || &t_Co == 256
call s:hi('Todo', '202', '', 'bold')
"" }}}
"" NVIM Groups {{
call s:hi('NormalFloat', '', '235', '')
"" }}
"" Terminal Groups {{{
call s:hi('debugBreakpoint', '1', '', 'reverse')
call s:hi('debugPC', '25', '', 'reverse')
@@ -207,16 +201,6 @@ if has('gui_running') || &t_Co == 256
call s:hi('ALEErrorSign', '160', '233', 'bold')
call s:hi('ALEWarningSign', '129', '233', 'bold')
call s:hi('CocErrorSign', '160', '233', '')
call s:hi('CocErrorFloat', '160', '235', '')
call s:hi('CocWarningSign', '129', '233', '')
call s:hi('CocWarningFloat', '129', '235', '')
call s:hi('CocInfoSign', '8', '233', '')
call s:hi('CocInfoFloat', '8', '235', '')
call s:hi('CocHintSign', '33', '233', '')
call s:hi('CocHintFloat', '33', '235', '')
call s:hi('CocInlayHint', '8', '', '')
call s:hi('SyntasticErrorSign', '160', '233', 'bold')
call s:hi('SyntasticWarningSign', '129', '233', 'bold')
call s:hi('SyntasticErrorLine', '', '', '')

View File

@@ -1 +0,0 @@
autocmd BufNewFile,BufReadPost */requirements.txt set filetype=requirements

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,6 +1,3 @@
" Add <> to % matches
setlocal matchpairs+=<:>
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#clang_format()
set formatexpr=format#clang_format()
endif

View File

@@ -1,3 +1,3 @@
if has('pythonx')
setlocal formatexpr=format#yapf()
set formatexpr=format#yapf()
endif

View File

@@ -1 +0,0 @@
set commentstring=#%s

View File

@@ -1,12 +0,0 @@
if exists(':GuiFont')
if platform#is_windows()
GuiFont! Source\ Code\ Pro:h10
else
GuiFont Source\ Code\ Pro:h9
endif
endif
if exists(':GuiTabline')
" Don't use GUI tabline, matches terminal tabline.
GuiTabline 0
endif

2
gvimrc
View File

@@ -6,7 +6,7 @@
set guioptions=aegi
if platform#is_windows()
set guifont=Source\ Code\ Pro:h10
set guifont=Consolas:h10:cDEFAULT
else
" Set default font
set guifont=Source\ Code\ Pro\ Medium\ 9

View File

@@ -1 +0,0 @@
runtime vimrc

1
init.vim Symbolic link
View File

@@ -0,0 +1 @@
vimrc

View File

@@ -1,28 +0,0 @@
---
- name: nodejs get json containing latest version
uri:
url: https://nodejs.org/dist/index.json
register: latest
- name: nodejs create directory for downloaded package
file:
state: directory
dest: ~/.local/src
- name: nodejs download latest package
get_url:
url: 'https://nodejs.org/dist/{{latest.json[0].version}}/node-{{latest.json[0].version}}-linux-x64.tar.gz'
dest: ~/.local/src/node.tar.gz
- name: nodejs extract downloaded package
unarchive:
src: ~/.local/src/node.tar.gz
dest: ~/.local/src
remote_src: true
- name: nodejs create symlink links
file:
state: link
src: '~/.local/src/node-{{latest.json[0].version}}-linux-x64/bin/{{item}}'
dest: '~/.local/bin/{{item}}'
with_items: [corepack, node, npm, npx]

View File

@@ -12,6 +12,9 @@ augroup benieAugroup
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\ | exe "normal! g'\"" | endif
" Highlight conflict markers in any filetype
au FileType * call matchadd('Todo', '^\(<<<<<<<\s.*\||||||||\|=======\|>>>>>>>\s.*\)$')
" Update `Last change: <date>` on write & go back previous cursor position
au FileType help au BufWritePre <buffer>
\ 1s/Last change: \zs.*$/\=strftime('%Y %b %d')/e|norm!``

View File

@@ -8,5 +8,7 @@ if !platform#is_windows() &&
echo "Setup the shell to do something similar on load"
echo "env TERM=xterm-256color /usr/bin/zsh"
endif
if !platform#is_windows() || has("gui_running")
colorscheme fresh
endif
syntax sync minlines=1000

View File

@@ -1,3 +1,11 @@
" minpac
function! s:minpac_init() abort
packadd minpac | call minpac#init() | source $MYVIMRC
endfunction
command! PackUpdate call s:minpac_init() | call minpac#update('', {'do': 'call minpac#status()'})
command! PackStatus call s:minpac_init() | call minpac#status()
command! PackClean call s:minpac_init() | call minpac#clean()
" Sort Python Imports
command! ISort call do#isort()

View File

@@ -5,8 +5,6 @@ nmap <silent> <leader>gt <Plug>(coc-type-definition)
nmap <silent> <leader>sd <Plug>(coc-diagnostic-info)
nmap <silent> <leader>gr <Plug>(coc-references)
nmap <silent> K :call do#show_documentation()<CR>
nmap <silent> <C-n> <Plug>(coc-diagnostic-next)
nmap <silent> <C-p> <Plug>(coc-diagnostic-prev)
if has('nvim')
" Make nvim :terminal more like vim :terminal
@@ -22,6 +20,10 @@ tnoremap <C-G> :Gdb<CR>
tnoremap <C-E> :Program<CR>
tnoremap <C-S> :Source<CR>
" GitGutter
nnoremap <leader>gn :GitGutterNextHunk<CR>
nnoremap <leader>gp :GitGutterPrevHunk<CR>
" Quickfix list
nnoremap <leader>qo :copen<CR>
nnoremap <leader>qc :cclose<CR>
@@ -64,7 +66,6 @@ nnoremap k gk
nnoremap <leader>w :w!<CR>
" Switch panes in a tmux aware way
if !has('win32')
nnoremap <silent> <C-h> :TmuxNavigateLeft<CR>
nnoremap <silent> <C-j> :TmuxNavigateDown<CR>
nnoremap <silent> <C-k> :TmuxNavigateUp<CR>
@@ -84,12 +85,6 @@ if !has('win32')
tnoremap <silent> <C-w>k <C-w>N:TmuxNavigateUp<CR>
tnoremap <silent> <C-w>l <C-w>N:TmuxNavigateRight<CR>
endif
else
nnoremap <silent> <C-h> <C-w>h
nnoremap <silent> <C-j> <C-w>j
nnoremap <silent> <C-k> <C-w>k
nnoremap <silent> <C-l> <C-w>l
endif
" Quick tabs
nnoremap <leader>tn :tabnew<Space>
@@ -115,10 +110,6 @@ else
noremap <leader>p "+p
noremap <leader>P "+P
endif
if has('nvim-0.5.2')
" Undo neovim's default mapping of Y to y$
unmap Y
endif
" Quickly access spelling menu
inoremap <C-s> <C-g>u<C-X>s

View File

@@ -176,7 +176,7 @@ if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
endif
" Change cursor dependant on current mode
if !has('nvim') && has('cursorshape') && has('unix') && !has('gui_running')
if has('cursorshape') && has('unix') && !has('gui_running')
if $TMUX ==# '' && $ITERM_PROFILE !=# ''
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"

View File

@@ -17,7 +17,7 @@ let g:statusline#dark_grey = {'fg': ['244', '#808080'], 'bg': ['233', '#12121
function! s:hi(group, color) abort
execute 'highlight '.a:group
\.' ctermfg='.a:color['fg'][0].' ctermbg='.a:color['bg'][0]
\.' guifg='.a:color['fg'][1].' guibg='.a:color['bg'][1]
\.' guifg='.a:color['fg'][1].' guibg='.a:color['fg'][1]
endfunction
" StatusLineLight is shows the mode and cursor information, it is dynamically
@@ -49,7 +49,7 @@ function! statusline#special(group, name, title)
endfunction
" Construct a statusline for generic buffer types.
function! statusline#generic(group, mode, coc)
function! statusline#generic(group, mode)
" Display current mode with dynamic highlights.
let l:mode = '%#'.a:group.'# '.a:mode.' '
" Display spell or paste if set with dusk highlights in a group to swallow
@@ -59,12 +59,12 @@ function! statusline#generic(group, mode, coc)
\.'%{&paste ? "Paste " : ""}'
\.'%)'
" Display filename with dark or changed highlights.
let l:file = (&modified ? '%#StatusLineChange#' : '%#StatusLineDark#').' %<%f'
let l:file = (&modified ? '%#StatusLineChange#' : '%#StatusLineDark#').' %f'
" Display readonly and nomodifiable if set.
let l:state = '%#StatusLineDark#'
\.'%{&readonly ? " 🔒" : ""}'
\.'%{&modifiable ? "" : " ⛔"}'
if a:coc && exists('*coc#status')
if exists('*coc#status')
" Display coc.nvim status.
let l:coc = '%#StatusLineDuskFade#%( %{coc#status()}%)'
else
@@ -108,11 +108,11 @@ function! statusline#active()
if l:mode ==# 'Normal'
let l:mode = 'Preview'
endif
return statusline#generic('StatusLineLight', l:mode, v:false)
return statusline#generic('StatusLineLight', l:mode)
elseif &filetype ==# 'man'
return statusline#special('StatusLineDusk', 'Manual', '%f')
endif
return statusline#generic('StatusLineLight', l:mode, v:true)
return statusline#generic('StatusLineLight', l:mode)
endfunction
" Define inactive statusline, this remains static until the buffer gains
@@ -130,11 +130,11 @@ function! statusline#inactive()
elseif &buftype ==# 'terminal'
let l:statusline = statusline#special('StatusLineDusk', 'Terminal', '%f')
elseif &previewwindow
let l:statusline = statusline#generic('StatusLineDusk', 'Preview', v:false)
let l:statusline = statusline#generic('StatusLineDusk', 'Preview')
elseif &filetype ==# 'man'
let l:statusline = statusline#special('StatusLineDusk', 'Manual', '%f')
else
let l:statusline = statusline#generic('StatusLineDusk', 'Idle', v:false)
let l:statusline = statusline#generic('StatusLineDusk', 'Idle')
endif
" Escape spaces and double quotes for use in setlocal.
let l:statusline = substitute(l:statusline, '\([ "]\)', '\\\0', 'g')

Binary file not shown.

View File

@@ -1,11 +0,0 @@
if exists('b:current_syntax')
finish
endif
highlight default link requirementsComment Comment
highlight default link requirementsVersion Identifier
highlight default link requirementsOperator Operator
syntax region requirementsComment start='^\w*#' end='$' contains=@Spell
syntax match requirementsVersion '\d\+\.\d\+\.\d\+\w*'
syntax match requirementsOperator '=='

View File

@@ -1,17 +0,0 @@
---
- include_vars: ~/.config/nvim/vars.yaml
- name: clone plugin repos
when: ansible_os_family != "Windows"
git:
repo: 'https://github.com/{{item.repo}}.git'
dest: '~/.config/nvim/pack/minpac/{{lookup("vars", "item.mode", default="start")}}/{{item.repo | regex_replace("^.*\/(.*)$", "\1")}}'
version: '{{lookup("vars", "item.branch", default="HEAD")}}'
with_items: '{{plugins}}'
- name: clone plugin repos
when: ansible_os_family == "Windows"
win_git:
repo: 'https://github.com/{{item.repo}}.git'
dest: '{{ansible_env.LOCALAPPDATA}}/nvim/pack/minpac/{{lookup("vars", "item.mode", default="start")}}/{{item.repo | regex_replace("^.*\/(.*)$", "\1")}}'
version: '{{lookup("vars", "item.branch", default="HEAD")}}'

View File

@@ -1,66 +0,0 @@
---
plugins:
- repo: mkitt/tabline.vim
- repo: neoclide/coc.nvim
branch: release
- repo: SirVer/ultisnips
- repo: honza/vim-snippets
- repo: vim-scripts/vimomni
mode: opt
- repo: w0rp/ale
- repo: mhinz/vim-signify
# Text Objects
- repo: kana/vim-textobj-user
# TODO: Doesn't work with nvim
- repo: kana/vim-textobj-entire
- repo: sgur/vim-textobj-parameter
- repo: jceb/vim-textobj-uri
- repo: glts/vim-textobj-comment
- repo: reedes/vim-textobj-sentence
# Tim Pope
- repo: tpope/vim-commentary
- repo: tpope/vim-surround
- repo: tpope/vim-repeat
- repo: tpope/vim-fugitive
- repo: tpope/vim-eunuch
- repo: tpope/vim-vinegar
- repo: tpope/vim-abolish
- repo: tpope/vim-unimpaired
- repo: tpope/vim-speeddating
- repo: godbyk/vim-endwise
branch: patch-1
- repo: tpope/vim-jdaddy
- repo: tpope/vim-projectionist
# Still necessary?
- repo: junegunn/fzf
- repo: junegunn/fzf.vim
# Forgot about this...
- repo: kbenzie/note.vim
# TODO: Move to tmux role?
# Pack 'christoomey/vim-tmux-navigator'
# Pack 'tmux-plugins/vim-tmux-focus-events'
- repo: wincent/replay
- repo: andymass/vim-matchup
- repo: dhruvasagar/vim-table-mode
- repo: vim-scripts/DoxygenToolkit.vim
mode: opt
- repo: guns/xterm-color-table.vim
# Syntax
- repo: kalekundert/vim-coiled-snake
- repo: kbenzie/vim-spirv
- repo: rperier/vim-cmake-syntax
- repo: tikhomirov/vim-glsl
- repo: beyondmarc/hlsl.vim
- repo: frasercrmck/opencl.vim
- repo: asciidoc/vim-asciidoc
- repo: mustache/vim-mustache-handlebars
- repo: joshglendenning/vim-caddyfile
- repo: kbenzie/vim-khr
- repo: jrozner/vim-antlr

28
vimrc
View File

@@ -11,6 +11,14 @@ if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
if exists('*minpac#init')
" When minpac is loaded define the Pack command to add packages.
command! -nargs=+ Pack call minpac#add(<args>)
else
" Otherwise define the Pack command to do nothing.
command! -nargs=+ Pack
endif
" Append work config to runtimepath and packpath.
set runtimepath+=~/.config/work
set packpath+=~/.config/work
@@ -18,13 +26,12 @@ set packpath+=~/.config/work
" tabline.vim - sanely numbered tabs
Pack 'mkitt/tabline.vim'
" coc.nvim - Conqueror of Completion
" coc.nvim Conqueror of Completion
Pack 'neoclide/coc.nvim', {'branch': 'release'}
let g:coc_global_extensions = [
\ 'coc-clangd',
\ 'coc-cmake',
\ 'coc-css',
\ 'coc-docker',
\ 'coc-html',
\ 'coc-jedi',
\ 'coc-json',
@@ -34,12 +41,6 @@ let g:coc_global_extensions = [
\ 'coc-vimlsp',
\ 'coc-yaml',
\]
if has("win32")
let g:coc_global_extensions += [
\ 'coc-powershell'
\]
endif
let g:coc_default_semantic_highlight_groups = 0
" ultisnips - snippet engine
Pack 'SirVer/ultisnips'
@@ -56,11 +57,8 @@ let g:ale_linters = {'c': [], 'cpp': []}
let g:ale_cmake_cmakelint_options =
\ '-convention/filename,-package/consistency,-package/stdargs'
" vim-signify - Version control differences in the sign column
" Version control differences in the sign column
Pack 'mhinz/vim-signify'
let g:signify_sign_change = '~'
" Conflict marker utilities
Pack 'rhysd/conflict-marker.vim'
" vim-textobj-user - library for creating text objects
Pack 'kana/vim-textobj-user'
@@ -96,10 +94,6 @@ Pack 'tpope/vim-fugitive'
Pack 'tpope/vim-eunuch'
" vim-vinegar - improved directory browser
Pack 'tpope/vim-vinegar'
if wsl#isDetected()
" Make gx work in WSL
let g:netrw_browsex_viewer='cmd.exe /C start'
endif
" vim-abolish - CamelCase to under_score to mixedCase
" TODO: Copy the good bit remove this plugin
Pack 'tpope/vim-abolish'
@@ -165,7 +159,7 @@ let g:rst_syntax_code_list = {
\ 'python': ['python']
\ }
" vim-coiled-snake - Python folding
" Python folding
Pack 'kalekundert/vim-coiled-snake'
" Enable builtin syntax folding