config nvim with fennel??

This commit is contained in:
elkowar 2021-04-02 19:54:14 +02:00
parent a23e8836f3
commit 8288adf664
7 changed files with 276 additions and 87 deletions

83
fnl/init.fnl Normal file
View file

@ -0,0 +1,83 @@
(module init
{require {a aniseed.core
nvim aniseed.nvim}
require-macros [macros]
include {keybinds keybinds}})
(set nvim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed.")
(local lsp (require "lspconfig"))
(local util lsp.util)
(local saga (require "lspsaga"))
(local compe (require "compe"))
(fn on_attach [client bufnr]
(if client.resolved_capabilities.document_highlight
(nvim.api.nvim_exec
"hi LspReferenceRead cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
hi LspReferenceText cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
hi LspReferenceWrite cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
"
false)))
(lsp.rust_analyzer.setup { :on_attach on_attach})
(lsp.jsonls.setup { :on_attach on_attach})
(lsp.vimls.setup { :on_attach on_attach})
(lsp.tsserver.setup { :on_attach on_attach})
(lsp.bashls.setup { :on_attach on_attach})
(lsp.html.setup { :on_attach on_attach})
(lsp.denols.setup
{ :on_attach on_attach
:root_dir (lsp.util.root_pattern ".git")})
(lsp.hls.setup
{ :on_attach on_attach
:settings { :languageServerHaskell { :formattingProvider "stylish-haskell"}}})
(compe.setup
{ :enabled true
:autocomplete true
:debug false
:min_length 1
:preselect "enable"
:throttle_time 80
:source_timeout 200
:incomplete_delay 400
:max_abbr_width 100
:max_kind_width 100
:max_menu_width 100
:documentation true
:source { :path true
:buffer true
:calc true
:nvim_lsp true
:nvim_lua true
:vsnip false}})
(saga.init_lsp_saga
{ :border_style 1
:code_action_keys { :quit "<esc>" :exec "<CR>"}
:rename_action_keys { :quit "<esc>" :exec "<CR>"}
:finder_action_keys
{ :quit "<esc>"
:open "<CR>"
:vsplit "v"
:split "b"
:scroll_up "<C-u>"
:scroll_down "<C-d>"}})

78
fnl/keybinds.fnl Normal file
View file

@ -0,0 +1,78 @@
(module keybinds
{require {a aniseed.core
nvim aniseed.nvim
util util}
require-macros [macros]})
(util.noremap :n :<leader> ":<c-u>WhichKey '<Space>'<CR>")
(util.noremap :v :<leader> ":<c-u>WhichKeyVisual '<Space>'<CR>")
(util.mapexpr :i :<C-Space> "compe#complete()")
(util.mapexpr :i :<CR> "compe#confirm('<CR>')")
(util.mapexpr :i :<esc> "compe#complete('<esc>')")
(fn le [s] (.. ":call luaeval \"" s "\")"))
(set nvim.g.which_key_map {})
(nvim.command "call which_key#register('<Space>', \"g:which_key_map\")")
(set nvim.g.which_key_map
{ "h" [ ":bprevious" "previous buffer"]
"l" [ ":bnext" "next buffer"]
"f" "which_key_ignore"
"s" "which_key_ignore"
"[" ["<Plug>(YoinkPostPasteSwapBack)" "Swap last paste backwards"]
"]" ["<Plug>(YoinkPostPasteSwapForward)" "Swap last paste backwards"]
":" [":Commands" "Search command with fzf"]
"c" { :name "+comment_out"}
"e" { :name "+emmet"}
"z" { :name "+folds"
"c" ["foldclose" "close fold"]
"o" ["foldopen" "open fold"]}
"m" { :name "+Code-actions"
"d" [ ":Lspsaga hover_doc" "show documentation"]
"b" [ ":Lspsaga lsp_finder" "find stuff"]
"x" [ ":Lspsaga preview_definition" "Preview definition"]
"o" [ ":Telescope lsp_document_symbols" "symbols in document"]
"s" [ ":Telescope lsp_workspace_symbols" "symbols in workspace"]
"t" [ ":Lspsaga signature_help" "Show signature help"]
"n" [ ":Lspsaga rename" "rename"]
"v" [ ":Lspsaga code_action" "apply codeaction"]
"a" [ ":Lspsaga show_cursor_diagnostics" "Cursor diagnostics"]
"A" [ ":Lspsaga show_line_diagnostics" "Line diagnostics"]
"E" [ ":Telescope lsp_workspace_diagnostics" "List diagnostics"]
"e" [ (le "vim.lsp.diagnostic.goto_next()") "Jump to the next error"]
"g" [ (le "vim.lsp.buf.definition()") "go to definition"]
"i" [ (le "vim.lsp.buf.implementation()") "show implementation"]
"r" [ (le "vim.lsp.buf.references()") "show references"]
"f" [ (le "vim.lsp.buf.formatting()") "format file"]}
"f" { :name "+folds"
"o" [ ":foldopen" "open fold"]
"n" [ ":foldclose" "close fold"]
"j" [ "zj" "jump to next fold"]
"k" [ "zk" "jump to previous fold"]}
"v" { :name "+view-and-layout"
"n" [":set relativenumber!" "toggle relative numbers"]
"m" [":set nonumber! norelativenumber" "toggle numbers"]
"g" [":Goyo | set linebreak" "toggle focus mode"]
"i" [":IndentGuidesToggle" "toggle indent guides"]}})
(set nvim.o.timeoutlen 200)
; TODO
; autocmd! VimEnter * :unmap <space>ig
; autocmd! FileType which_key)

19
fnl/macros.fnl Normal file
View file

@ -0,0 +1,19 @@
{:augroup
(fn [name ...]
`(do
(nvim.ex.augroup ,(tostring name))
(nvim.ex.autocmd_)
,...
(nvim.ex.augroup :END)))
:autocmd
(fn [...]
`(nvim.ex.autocmd ,...))
:_:
(fn [name ...]
`((. nvim.ex ,(tostring name)) ,...))
:viml->fn
(fn [name]
`(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))}

13
fnl/util.fnl Normal file
View file

@ -0,0 +1,13 @@
(module util
{require {a aniseed.core
nvim aniseed.nvim}
require-macros [macros]})
(defn noremap [mode from to]
"Sets a mapping with {:noremap true :silent true}."
(nvim.set_keymap mode from to {:noremap true :silent true}))
(defn mapexpr [mode from to]
"Sets a mapping with {:noremap true :silent true :expr true}."
(nvim.set_keymap mode from to {:noremap true :silent true :expr true}))

View file

@ -54,7 +54,7 @@ set autoindent smartindent noet expandtab
set nowrap
set noshowmode " hide the mode as shown by vim, because the status line does it better!
set completeopt=longest,menuone " Enable autocompletion
set completeopt=longest,menuone,noselect " Enable autocompletion
set laststatus=2
set noshowmode
@ -353,14 +353,13 @@ source $VIM_ROOT/whichkeyConfig.vim
luafile $VIM_ROOT/lsp.lua
"source $VIM_ROOT/lsp.vim
" this is apparently necessary for nvim-lsp stuff
set completeopt=menuone,noselect
let g:aniseed#env = v:true
inoremap <silent><expr> <C-Space> compe#complete()
inoremap <silent><expr> <CR> compe#confirm('<CR>')
inoremap <silent><expr> <esc> compe#close('<esc>')
"inoremap <silent><expr> <C-Space> compe#complete()
"inoremap <silent><expr> <CR> compe#confirm('<CR>')
"inoremap <silent><expr> <esc> compe#close('<esc>')
"nnoremap <silent> <C-d> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>

View file

@ -10,6 +10,9 @@ call plug#begin('~/.vim/plugged')
Plug 'Olical/aniseed', { 'tag': 'v3.16.0' }
Plug 'bakpakin/fennel.vim'
" general purpose lua wrappers for nvim stuff
Plug 'norcalli/nvim.lua'
Plug 'tweekmonster/startuptime.vim'
Plug 'tpope/vim-repeat'
@ -128,11 +131,14 @@ call plug#begin('~/.vim/plugged')
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'thyrgle/vim-dyon'
Plug 'bakpakin/fennel.vim'
Plug 'tjdevries/nlua.nvim'
Plug 'nvim-lua/completion-nvim'
"Plug 'mxw/vim-prolog'
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-compe'
Plug 'glepnir/lspsaga.nvim'

View file

@ -1,7 +1,7 @@
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>'WhichKeyVisual '<Space>'<CR>
let g:which_key_map = {}
call which_key#register('<Space>', "g:which_key_map")
"nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
"vnoremap <silent> <leader> :<c-u>'WhichKeyVisual '<Space>'<CR>
"let g:which_key_map = {}
"call which_key#register('<Space>', "g:which_key_map")
@ -10,18 +10,18 @@ call which_key#register('<Space>', "g:which_key_map")
"\ 'h' : 'which_key_ignore', 'l' : 'which_key_ignore' ,
"\ 'h' : ':bprevious', 'l' : ':bnext' ,
"\ 'h' : [':BufferPrevious', 'prev buffer'], 'l' : [':BufferNext', 'next buffer'] ,
let g:which_key_map = {
\ 'h' : [':bprevious', 'prev buffer'], 'l' : [':bnext', 'next buffer'],
\ 'f' : 'which_key_ignore', 's': 'which_key_ignore' ,
\ 'c' : { 'name': '+comment_out' },
\ 'e' : { 'name': '+emmet' },
\ '[' : ['<Plug>(YoinkPostPasteSwapBack)', 'Swap last paste backwards' ],
\ ']' : ['<Plug>(YoinkPostPasteSwapForward)', 'Swap last paste backwards' ],
\ ':' : [':Commands' , 'Search command with fzf' ],
\ 'z' : { 'name': '+folds', 'c': ['foldclose', 'close fold'],
\ 'o': ['foldopen', 'open fold'] ,
\ }
\ }
"let g:which_key_map = {
"\ 'h' : [':bprevious', 'prev buffer'], 'l' : [':bnext', 'next buffer'],
"\ 'f' : 'which_key_ignore', 's': 'which_key_ignore' ,
"\ 'c' : { 'name': '+comment_out' },
"\ 'e' : { 'name': '+emmet' },
"\ '[' : ['<Plug>(YoinkPostPasteSwapBack)', 'Swap last paste backwards' ],
"\ ']' : ['<Plug>(YoinkPostPasteSwapForward)', 'Swap last paste backwards' ],
"\ ':' : [':Commands' , 'Search command with fzf' ],
"\ 'z' : { 'name': '+folds', 'c': ['foldclose', 'close fold'],
"\ 'o': ['foldopen', 'open fold'] ,
"\ }
"\ }
"\ 's' : [ ':CocFzfList symbols' , 'list symbols' ] ,
@ -45,25 +45,26 @@ let g:which_key_map = {
"\ 'a' : [ ':call luaeval("vim.lsp.diagnostic.show_line_diagnostics()")' , 'diagnostics info' ] ,
"\ }
let g:which_key_map['m'] = {
\ 'name' : '+Code-actions' ,
\ 'd' : [ ':Lspsaga hover_doc' , 'show documentation' ] ,
\ 'b' : [ ':Lspsaga lsp_finder' , 'find stuff' ] ,
\ 'x' : [ ':Lspsaga preview_definition' , 'Preview definition' ] ,
\ 'o' : [ ':Telescope lsp_document_symbols' , 'symbols in document' ] ,
\ 's' : [ ':Telescope lsp_workspace_symbols' , 'symbols in workspace' ] ,
\ 'g' : [ ':call luaeval("vim.lsp.buf.definition()")' , 'go to definition' ] ,
\ 't' : [ ':Lspsaga signature_help' , 'Show signature help' ] ,
\ 'i' : [ ':call luaeval("vim.lsp.buf.implementation()")' , 'show implementation' ] ,
\ 'r' : [ ':call luaeval("vim.lsp.buf.references()")' , 'show references' ] ,
\ 'n' : [ ':Lspsaga rename' , 'rename' ] ,
\ 'f' : [ ':call luaeval("vim.lsp.buf.formatting()")' , 'format file' ] ,
\ 'v' : [ ':Lspsaga code_action' , 'apply codeaction' ] ,
\ 'e' : [ ':call luaeval("vim.lsp.diagnostic.goto_next()")' , 'Jump to the next error' ] ,
\ 'E' : [ ':Telescope lsp_workspace_diagnostics' , 'List diagnostics' ] ,
\ 'a' : [ ':Lspsaga show_cursor_diagnostics' , 'Cursor diagnostics' ] ,
\ 'A' : [ ':Lspsaga show_line_diagnostics' , 'Line diagnostics' ] ,
\ }
" this is the one!
"let g:which_key_map['m'] = {
"\ 'name' : '+Code-actions' ,
"\ 'd' : [ ':Lspsaga hover_doc' , 'show documentation' ] ,
"\ 'b' : [ ':Lspsaga lsp_finder' , 'find stuff' ] ,
"\ 'x' : [ ':Lspsaga preview_definition' , 'Preview definition' ] ,
"\ 'o' : [ ':Telescope lsp_document_symbols' , 'symbols in document' ] ,
"\ 's' : [ ':Telescope lsp_workspace_symbols' , 'symbols in workspace' ] ,
"\ 'g' : [ ':call luaeval("vim.lsp.buf.definition()")' , 'go to definition' ] ,
"\ 't' : [ ':Lspsaga signature_help' , 'Show signature help' ] ,
"\ 'i' : [ ':call luaeval("vim.lsp.buf.implementation()")' , 'show implementation' ] ,
"\ 'r' : [ ':call luaeval("vim.lsp.buf.references()")' , 'show references' ] ,
"\ 'n' : [ ':Lspsaga rename' , 'rename' ] ,
"\ 'f' : [ ':call luaeval("vim.lsp.buf.formatting()")' , 'format file' ] ,
"\ 'v' : [ ':Lspsaga code_action' , 'apply codeaction' ] ,
"\ 'e' : [ ':call luaeval("vim.lsp.diagnostic.goto_next()")' , 'Jump to the next error' ] ,
"\ 'E' : [ ':Telescope lsp_workspace_diagnostics' , 'List diagnostics' ] ,
"\ 'a' : [ ':Lspsaga show_cursor_diagnostics' , 'Cursor diagnostics' ] ,
"\ 'A' : [ ':Lspsaga show_line_diagnostics' , 'Line diagnostics' ] ,
"\ }
"let g:which_key_map['m'] = {
"\ 'name' : '+Code-actions' ,
@ -89,54 +90,44 @@ let g:which_key_map['m'] = {
"\ 'O' : [ '<Plug>(coc-openlink)' , 'open link under cursor' ] ,
"\}
let g:which_key_map['f'] = {
\ 'name': '+folds',
\ 'o': [ ':foldopen' , 'open fold' ] ,
\ 'n': [ ':foldclose' , 'close fold' ] ,
\ 'j': [ 'zj' , 'jump to next fold' ] ,
\ 'k': [ 'zk' , 'jump to previous fold' ] ,
\ }
"let g:which_key_map['f'] = {
"\ 'name': '+folds',
"\ 'o': [ ':foldopen' , 'open fold' ] ,
"\ 'n': [ ':foldclose' , 'close fold' ] ,
"\ 'j': [ 'zj' , 'jump to next fold' ] ,
"\ 'k': [ 'zk' , 'jump to previous fold' ] ,
"\ }
let g:which_key_map['a'] = {
\ 'name': '+Bookmarks',
\ ' ' : ['<Plug>(coc-bookmark-toggle)' , 'toggle bookmark' ] ,
\ 'a' : ['<Plug>(coc-bookmark-annotate)' , 'annotate bookmark' ] ,
\ 'j' : ['<Plug>(coc-bookmark-next)' , 'next bookmark' ] ,
\ 'k' : ['<Plug>(coc-bookmark-prev)' , 'prev bookmark' ] ,
\ 'l' : [':CocList bookmark' , 'list bookmarks' ] ,
\ 'c' : [':CocCommand bookmark.clearForCurrentFile' , 'clear for current file' ] ,
\ 'C' : [':CocCommand bookmark.clearForAllFiles' , 'clear for all files' ]
\}
" mappings for view and layout
let g:which_key_map['v'] = {
\ 'name' : '+view-and-layout',
\ 'n' : [':set relativenumber!' , 'toggle relative numbers' ] ,
\ 'm' : [':set nonumber! norelativenumber' , 'toggle numbers'] ,
\ 'g' : [':Goyo | set linebreak' , 'toggle focus mode' ] ,
\ 'i' : [':IndentGuidesToggle' , 'toggle indent guides' ] ,
\ }
"" mappings for view and layout
"let g:which_key_map['v'] = {
"\ 'name' : '+view-and-layout',
"\ 'n' : [':set relativenumber!' , 'toggle relative numbers' ] ,
"\ 'm' : [':set nonumber! norelativenumber' , 'toggle numbers'] ,
"\ 'g' : [':Goyo | set linebreak' , 'toggle focus mode' ] ,
"\ 'i' : [':IndentGuidesToggle' , 'toggle indent guides' ] ,
"\ }
" :bwipeout! bdelete!
"\ 'b' : ['BufferPick' , 'select open buffer' ] ,
"\ 'c' : ['BufferClose', 'close open buffer' ] ,
"\ 'w' : ['BufferWipeout', 'wipeout open buffer' ] ,
let g:which_key_map['b'] = {
\ 'name': '+buffers',
\ 'b' : [':Buffers' , 'select open buffer' ] ,
\ 'c' : [':bdelete!', 'close open buffer' ] ,
\ 'w' : [':bwipeout!', 'wipeout open buffer' ] ,
\ }
"" :bwipeout! bdelete!
""\ 'b' : ['BufferPick' , 'select open buffer' ] ,
""\ 'c' : ['BufferClose', 'close open buffer' ] ,
""\ 'w' : ['BufferWipeout', 'wipeout open buffer' ] ,
"let g:which_key_map['b'] = {
"\ 'name': '+buffers',
"\ 'b' : [':Buffers' , 'select open buffer' ] ,
"\ 'c' : [':bdelete!', 'close open buffer' ] ,
"\ 'w' : [':bwipeout!', 'wipeout open buffer' ] ,
"\ }
let g:which_key_map['x'] = {
\ 'name' : '+other',
\ 'f' : ['NERDTreeToggle' , '<Ctrl+F> show file tree'],
\ 'p' : ['FZF' , '<Ctrl+p> search file (c-v/c-x to open in split)' ] ,
\ 'h' : [':History:' , 'search command history'],
\ 'c' : [':Commands' , 'search through commands'],
\ 's' : ['OverCommandLine', 'Substitute with preview'],
\ 'y' : [':CocFzfList yank', 'Show yank history']
\ }
"let g:which_key_map['x'] = {
"\ 'name' : '+other',
"\ 'f' : ['NERDTreeToggle' , '<Ctrl+F> show file tree'],
"\ 'p' : ['FZF' , '<Ctrl+p> search file (c-v/c-x to open in split)' ] ,
"\ 'h' : [':History:' , 'search command history'],
"\ 'c' : [':Commands' , 'search through commands'],
"\ 's' : ['OverCommandLine', 'Substitute with preview'],
"\ 'y' : [':CocFzfList yank', 'Show yank history']
"\ }
" CocList -A --normal yank needs :CocInstall coc-yank
@ -148,5 +139,5 @@ let g:which_key_map['x'] = {
"autocmd! FileType which_key set laststatus=2 noshowmode noruler
"\| autocmd! BufLeave <buffer> set laststatus=2 showmode ruler
set timeoutlen=200
"set timeoutlen=200