More neovim config changes
diff --git a/modules/neovim/binds/binds.vim b/modules/neovim/binds/binds.vim
index 94390b7..83df6b0 100644
--- a/modules/neovim/binds/binds.vim
+++ b/modules/neovim/binds/binds.vim
@@ -1,5 +1,8 @@
set whichwrap=b,s,<,>,[,]
-set mouse=a
+" set mouse=a
+
+nmap <C-k> :m-2<CR>
+nmap <C-j> :m+1<CR>
vnoremap <F12> <Esc>
inoremap <F12> <Esc>
diff --git a/modules/neovim/brackets/default.nix b/modules/neovim/brackets/default.nix
new file mode 100644
index 0000000..45731f4
--- /dev/null
+++ b/modules/neovim/brackets/default.nix
@@ -0,0 +1,6 @@
+{pkgs, ...}: {
+ programs.neovim = {
+ plugins = [pkgs.vimPlugins.pear-tree];
+ extraConfig = builtins.readFile ./pear-tree.vim;
+ };
+}
diff --git a/modules/neovim/brackets/pear-tree.vim b/modules/neovim/brackets/pear-tree.vim
new file mode 100644
index 0000000..0f947bb
--- /dev/null
+++ b/modules/neovim/brackets/pear-tree.vim
@@ -0,0 +1,16 @@
+let g:pear_tree_smart_openers = 1
+let g:pear_tree_smart_closers = 1
+let g:pear_tree_smart_backspace = 1
+let g:pear_tree_map_special_keys = 0
+
+autocmd FileType tex let b:pear_tree_pairs = extend(deepcopy(g:pear_tree_pairs), {
+ \ '$': {'closer': '$'},
+ \ }, 'keep')
+autocmd FileType markdown let b:pear_tree_pairs = extend(deepcopy(g:pear_tree_pairs), {
+ \ '`': {'closer': '`'},
+ \ '```': {'closer': '```'},
+ \ '$': {'closer': '$'},
+ \ }, 'keep')
+
+imap <BS> <Plug>(PearTreeBackspace)
+imap <Esc> <Plug>(PearTreeFinishExpansion)
diff --git a/modules/neovim/coc/default.nix b/modules/neovim/coc/default.nix
index cfdfda9..80c2c6a 100644
--- a/modules/neovim/coc/default.nix
+++ b/modules/neovim/coc/default.nix
@@ -48,6 +48,7 @@
tables = false;
};
MD024.siblings_only = true;
+ MD037 = false;
};
languageserver = {
nix = {
@@ -85,9 +86,6 @@
# Snippet completion
vim-snippets
coc-snippets
-
- # General utilities
- coc-pairs
];
extraConfig = lib.pipe [./keybinds.vim ./theme.vim] [
(map builtins.readFile)
diff --git a/modules/neovim/coc/keybinds.vim b/modules/neovim/coc/keybinds.vim
index ae7e174..bbc1694 100644
--- a/modules/neovim/coc/keybinds.vim
+++ b/modules/neovim/coc/keybinds.vim
@@ -11,25 +11,47 @@
let g:UltiSnipsExpandTrigger="<NUL>"
let g:UltiSnipsJumpForwardTrigger="<NUL>"
let g:UltiSnipsJumpBackwardTrigger="<NUL>"
-inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<CR>"
+inoremap <silent><expr> <CR> coc#pum#visible() ? "\<C-g>u" . coc#pum#confirm() :
+ \ coc#jumpable() ? "\<C-g>u<Esc>:call coc#snippet#next()\<CR>" :
+ \ "\<Plug>(PearTreeExpand)"
inoremap <silent><expr> <Tab> coc#pum#visible() ? coc#pum#next(0) :
- \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
- \ CheckBackSpace() ? "\<TAB>" :
- \ coc#refresh()
+ \ coc#expandableOrJumpable() ? "\<C-g>u\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
+ \ (pear_tree#GetSurroundingPair() != [] ? pear_tree#insert_mode#JumpOut() : (CheckBackSpace() ? "\<TAB>" :
+ \ coc#refresh()))
function! CheckBackSpace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
-let g:coc_snippet_next = '<tab>'
-inoremap <silent><expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(0) : "\<S-Tab>"
+inoremap <silent><expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(0) :
+ \ coc#jumpable() ? "\<C-g>u<Esc>:call coc#snippet#prev()\<CR>" :
+ \ "\<S-Tab>"
xnoremap <silent> <Tab> <Plug>(coc-snippets-select)
+nnoremap <silent><expr> <CR> coc#jumpable() ?
+ \ ":call coc#snippet#next()\<CR>" :
+ \ "\<CR>"
-snoremap <nowait><silent> <Tab> <Esc>:call UltiSnips#JumpForwards()<cr>
-snoremap <nowait><silent> <S-Tab> <Esc>:call UltiSnips#JumpForwards()<cr>
+nnoremap <silent><expr> <Tab> coc#jumpable() ?
+ \ ":call coc#snippet#next()\<CR>" :
+ \ (pear_tree#GetSurroundingPair() != [] ? pear_tree#insert_mode#JumpOut() : "\<Tab>")
+nnoremap <silent><expr> <S-Tab> coc#jumpable() ?
+ \ ":call coc#snippet#prev()\<CR>" :
+ \ "\<S-Tab>"
+
+snoremap <silent><expr> <CR> coc#jumpable() ?
+ \ "\<C-g>u<Esc>:call coc#snippet#next()\<CR>" :
+ \ "\<CR>"
+
+snoremap <silent><expr> <Tab> coc#jumpable() ?
+ \ "\<C-g>u<Esc>:call coc#snippet#next()\<CR>" :
+ \ (pear_tree#GetSurroundingPair() != [] ? pear_tree#insert_mode#JumpOut() : "\<Tab>")
+
+snoremap <silent><expr> <S-Tab> coc#jumpable() ?
+ \ "\<C-g>u<Esc>:call coc#snippet#prev()\<CR>" :
+ \ "\<S-Tab>"
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
@@ -42,6 +64,3 @@
nnoremap <silent> K :call <SID>show_documentation()<CR>
command Snippets CocFzfList snippets
-
-autocmd FileType tex let b:coc_pairs = [["$", "$"]]
-autocmd FileType markdown let b:coc_pairs = [["$", "$"]]
diff --git a/modules/neovim/coc/snippets/all.snippets b/modules/neovim/coc/snippets/all.snippets
index 2ed085b..cb64ed3 100644
--- a/modules/neovim/coc/snippets/all.snippets
+++ b/modules/neovim/coc/snippets/all.snippets
@@ -1,3 +1,3 @@
-snippet visual "Get back the visual selection without any extra trimmings"
+snippet visual "Get back the visual selection without any extra trimmings" i
${VISUAL}
endsnippet
diff --git a/modules/neovim/coc/snippets/markdown.snippets b/modules/neovim/coc/snippets/markdown.snippets
index 041cddc..b6e7af8 100644
--- a/modules/neovim/coc/snippets/markdown.snippets
+++ b/modules/neovim/coc/snippets/markdown.snippets
@@ -40,7 +40,7 @@
endsnippet
snippet intd "Integrate definitely" i
-\int{${1}}{${2}}${3} \text{ d}${4:x}${0}
+\int^{${1}}_{${2}}${3} \text{ d}${4:x}${0}
endsnippet
snippet ihat "The I vector" i
@@ -80,3 +80,7 @@
snippet 2x2matrix "A 2 by 2 matrix" i
\begin{bmatrix} ${1} & ${2} \\\\ ${3} & ${4} \end{bmatrix}${0}
endsnippet
+
+snippet sum "A sum" i
+\sum^{${1:n}}_{${2:r}=${3:1}}${4}${0}
+endsnippet
diff --git a/modules/neovim/markdown/markdown.vim b/modules/neovim/markdown/markdown.vim
index 9092207..fcf8dcc 100644
--- a/modules/neovim/markdown/markdown.vim
+++ b/modules/neovim/markdown/markdown.vim
@@ -8,3 +8,5 @@
let g:pandoc#formatting#textwidth = 80
let g:pandoc#formatting#mode = "h"
let g:pandoc#spell#enabled = 0
+
+let g:mkdp_auto_close = 0
diff --git a/modules/neovim/support/filetypes.vim b/modules/neovim/support/filetypes.vim
index bf81528..0e07ef5 100644
--- a/modules/neovim/support/filetypes.vim
+++ b/modules/neovim/support/filetypes.vim
@@ -2,7 +2,7 @@
autocmd!
autocmd BufReadPre *.docx silent set ro
autocmd BufEnter *.docx silent set modifiable
- autocmd BufEnter *.docx silent %!pandoc -f docx -t markdown --wrap=preserve "%"
+ autocmd BufEnter *.docx silent %!pandoc -f docx -t markdown --columns=80 --quiet "%" | prettier --parser markdown
autocmd BufEnter *.docx silent set filetype=markdown
- autocmd BufEnter *.docx silent set nomodifiable
+" autocmd BufEnter *.docx silent set nomodifiable
augroup END
diff --git a/modules/neovim/wiki/wiki.vim b/modules/neovim/wiki/wiki.vim
index e891588..77d9100 100644
--- a/modules/neovim/wiki/wiki.vim
+++ b/modules/neovim/wiki/wiki.vim
@@ -18,7 +18,14 @@
function! TemplateFallback(context)
- call append(0, ['# ' . g:lastWikiOriginalName, ''])
+ echom "Creating new wiki page"
+ echom exists("g:lastWikiOriginalName")
+ if exists("g:lastWikiOriginalName")
+ call append(0, ['# ' . g:lastWikiOriginalName, ''])
+ unlet! g:lastWikiOriginalName
+ else
+ call append(0, ['# ' . context.name, ''])
+ endif
endfunction
let g:wiki_templates = [