diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2023-06-21 10:12:45 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2023-06-21 10:12:45 +0000 |
| commit | 0e07c01180b6abd84881b67e41e5f611d49e06db (patch) | |
| tree | c18df6080ec93d72c025282a714821e7ad7d51e3 /.config/nvim/ftplugin | |
| parent | 69c4711933e71649232028582e7719220e25e2c3 (diff) | |
Add neovim configuration
Diffstat (limited to '.config/nvim/ftplugin')
| -rw-r--r-- | .config/nvim/ftplugin/haskell.lua | 42 | ||||
| -rw-r--r-- | .config/nvim/ftplugin/markdown.vim | 10 | ||||
| -rw-r--r-- | .config/nvim/ftplugin/tex.vim | 108 |
3 files changed, 160 insertions, 0 deletions
diff --git a/.config/nvim/ftplugin/haskell.lua b/.config/nvim/ftplugin/haskell.lua new file mode 100644 index 0000000..6d06780 --- /dev/null +++ b/.config/nvim/ftplugin/haskell.lua @@ -0,0 +1,42 @@ +vim.g.haskell_enable_quantification = 1 -- to enable highlighting of `forall` +vim.g.haskell_enable_recursivedo = 1 -- to enable highlighting of `mdo` and `rec` +vim.g.haskell_enable_arrowsyntax = 1 -- to enable highlighting of `proc` +vim.g.haskell_enable_pattern_synonyms = 1 -- to enable highlighting of `pattern` +vim.g.haskell_enable_typeroles = 1 -- to enable highlighting of type roles +vim.g.haskell_enable_static_pointers = 1 -- to enable highlighting of `static` +vim.g.haskell_backpack = 1 -- to enable highlighting of backpack keywords + +local ht = require('haskell-tools') +local def_opts = { noremap = true, silent = true, } +ht.start_or_attach { + hls = { + on_attach = function(client, bufnr) + local opts = vim.tbl_extend('keep', def_opts, { buffer = bufnr, }) + -- haskell-language-server relies heavily on codeLenses, + -- so auto-refresh (see advanced configuration) is enabled by default + vim.keymap.set('n', '<space>ca', vim.lsp.codelens.run, opts) + vim.keymap.set('n', '<space>hs', ht.hoogle.hoogle_signature, opts) + vim.keymap.set('n', '<space>ea', ht.lsp.buf_eval_all, opts) + end, + }, +} + +-- Suggested keymaps that do not depend on haskell-language-server: +local bufnr = vim.api.nvim_get_current_buf() +-- set buffer = bufnr in ftplugin/haskell.lua +local opts = { noremap = true, silent = true, buffer = bufnr } + +-- enable hovering +vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + +-- Toggle a GHCi repl for the current package +vim.keymap.set('n', '<leader>rr', ht.repl.toggle, opts) +-- Toggle a GHCi repl for the current buffer +vim.keymap.set('n', '<leader>rf', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) +end, def_opts) +vim.keymap.set('n', '<leader>rq', ht.repl.quit, opts) + +-- Detect nvim-dap launch configurations +-- (requires nvim-dap and haskell-debug-adapter) +ht.dap.discover_configurations(bufnr) diff --git a/.config/nvim/ftplugin/markdown.vim b/.config/nvim/ftplugin/markdown.vim new file mode 100644 index 0000000..3902f56 --- /dev/null +++ b/.config/nvim/ftplugin/markdown.vim @@ -0,0 +1,10 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let g:markdown_fenced_languages = ['c', 'css', 'sh', 'vim', 'futhark'] +let g:markdown_minlines = 64 + +setlocal spell +setlocal spelllang=en_us diff --git a/.config/nvim/ftplugin/tex.vim b/.config/nvim/ftplugin/tex.vim new file mode 100644 index 0000000..9bf703d --- /dev/null +++ b/.config/nvim/ftplugin/tex.vim @@ -0,0 +1,108 @@ +function! GetMainDoc() + let l:maindoc = search('\\begin{document}', "cnw") + if l:maindoc > 0 + return '%' + else + " Find the main document file + " Must be in the same folder of the current file + let l:maindocscmd = "grep -lrE '\\\\begin{document}' " . expand('%:h') . "/*.tex" + let l:maindocssys = system(l:maindocscmd) + let l:maindocs = split(l:maindocssys) + if len(l:maindocs) > 0 + " Use the first document containing `begin{document}` + return l:maindocs[0] + else + return "" + endif + endif +endfunction + +function! CompileMainDoc() + let l:latexcmd ='autocmd BufWritePost <buffer> ! + \ latexrun --latex-args="-synctex=1 -interaction=nonstopmode" ' + + execute(l:latexcmd . GetMainDoc()) +endfunction + +"function! Synctex() +" " remove 'silent' for debugging +" let l:doc = GetMainDoc() +" execute "silent !mv -u latex.out/" . substitute(l:doc, '\.tex', '') . ".synctex.gz ." +" execute "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . bufname('%') . " " . expand('%:t:r') . ".pdf" +" redraw! +"endfunction +function! Synctex() + " remove 'silent' for debugging + execute "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . bufname('%') . " " . g:syncpdf + redraw! +endfunction +nmap <C-M> :call Synctex()<CR> + +setlocal spell +setlocal spelllang=en_us + +imap <buffer> FTT \texttt{}<Esc>i +imap <buffer> FBF \textbf{}<Esc>i +imap <buffer> FIT \textit{}<Esc>i +imap <buffer> FSC \textsc{}<Esc>i +imap <buffer> MTT \mathtt{}<Esc>i +imap <buffer> MBF \mathbf{}<Esc>i +imap <buffer> MIT \mathit{}<Esc>i +imap <buffer> MSC \mathsc{}<Esc>i + +imap <buffer> (( \left(\right)<Esc>F\i +imap <buffer> {{ \left\{\right\}<Esc>F\F\i +imap <buffer> [[ \left[\right]<Esc>F\i + +imap <buffer> ~~ \neg +imap <buffer> /\ \land +imap <buffer> \/ \lor +imap <buffer> -> \rightarrow +imap <buffer> ==> \Rightarrow +imap <buffer> <== \Leftarrow +imap <buffer> <=> \Leftrightarrow +imap <buffer> \|- \vdash +imap <buffer> \|= \vDash +imap <buffer> !-- \inference[]{%<CR>}{%<CR>}<ESC>kk$F[a +imap <buffer> !== \begin{align*}<CR>\end{align*}<ESC>O +imap <buffer> !ii \begin{itemize}<CR>\end{itemize}<ESC>O\item Case +imap <buffer> CC \item Case +imap <buffer> EIMP \expEimp{<++>}{<++>}{<++>}<ESC>F\<C-j> +imap <buffer> [[ [\![ +imap <buffer> ]] ]\!] + +imap <buffer> <leader>CI $\land\mbox{I}$ +imap <buffer> <leader>CE1 $\land\mbox{E}_1$ +imap <buffer> <leader>CE2 $\land\mbox{E}_2$ +imap <buffer> <leader>DI1 $\lor\mbox{I}_1$ +imap <buffer> <leader>DI2 $\lor\mbox{I}_2$ +imap <buffer> <leader>DE $\lor\mbox{E}$ +imap <buffer> <leader>II $\Rightarrow\mbox{I}$ +imap <buffer> <leader>IE $\Rightarrow\mbox{E}$ +imap <buffer> <leader>NE $\neg\mbox{E}$ +imap <buffer> <leader>NI $\neg\mbox{I}$ + +imap <buffer> MCC \mathcal{}<++><Esc>T{i + +inoremap <buffer> <C-j> <Esc>/<++><CR>cf> +noremap <buffer> <C-j> /<++><CR>cf> + +vnoremap <buffer> `it <ESC>`>a}<ESC>`<i\textit{<ESC> +vnoremap <buffer> `bf <ESC>`>a}<ESC>`<i\textbf{<ESC> +vnoremap <buffer> `tt <ESC>`>a}<ESC>`<i\texttt{<ESC> +vnoremap <buffer> `mi <ESC>`>a}<ESC>`<i\mathit{<ESC> +vnoremap <buffer> `mb <ESC>`>a}<ESC>`<i\mathbf{<ESC> +vnoremap <buffer> `mt <ESC>`>a}<ESC>`<i\mathtt{<ESC> + +" put \begin{} \end{} tags tags around the current word +vnoremap <C-B> YpkI\begin{<ESC>A}<ESC>jI\end{<ESC>A}<esc>kA + +syntax sync minlines=10000 +"setlocal spell spelllang=en_US + +call CompileMainDoc() + +" autocmd BufRead *.tex imap /\ \land +" autocmd BufRead *.tex imap \/ \lor +" autocmd BufRead *.tex imap -> \rightarrow +" autocmd BufRead *.tex imap ~~ \neg |
