this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Cleanup Vim configuration

+137 -129
+1
vim/.config/nvim/after/ftplugin/erlang.vim
··· 1 1 setlocal shiftwidth=4 2 + " setlocal expandtab 2 3 3 4 let b:undo_ftplugin = 'setl sw&'
+8
vim/.config/nvim/after/ftplugin/vimwiki.vim
··· 1 + call vimwiki#u#map_key('n', 'g=', '<Plug>VimwikiAddHeaderLevel') 2 + call vimwiki#u#map_key('n', 'g-', '<Plug>VimwikiRemoveHeaderLevel') 3 + call vimwiki#u#map_key('n', ']u', '<Plug>VimwikiGoToParentHeader') 4 + call vimwiki#u#map_key('n', '[u', '<Plug>VimwikiGoToParentHeader', 1) 5 + call vimwiki#u#map_key('n', ']]', '<Plug>VimwikiGoToNextHeader') 6 + call vimwiki#u#map_key('n', '[[', '<Plug>VimwikiGoToPrevHeader') 7 + call vimwiki#u#map_key('n', ']=', '<Plug>VimwikiGoToNextSiblingHeader') 8 + call vimwiki#u#map_key('n', '[=', '<Plug>VimwikiGoToPrevSiblingHeader')
-11
vim/.config/nvim/autoload/open.vim
··· 1 - function! open#open() abort 2 - if a:0 > 0 3 - let l:name = a:1 4 - else 5 - let l:name = expand('<cfile>') 6 - endif 7 - 8 - call jobstart(['open', l:name], { 'detach': v:true }) 9 - 10 - echo 'Open '.l:name 11 - endfunction
+7 -4
vim/.config/nvim/autoload/plugins.vim
··· 37 37 " }}} 38 38 " Git {{{ 39 39 call minpac#add('tpope/vim-fugitive') 40 + " call minpac#add('TimUntersberger/neogit') 41 + " call minpac#add('nvim-lua/popup.nvim') 42 + " call minpac#add('nvim-lua/plenary.nvim') 43 + " call minpac#add('pwntester/octo.nvim') 40 44 " }}} 41 45 " Launch screen {{{ 42 46 call minpac#add('mhinz/vim-startify') " Required during startup 43 47 " }}} 44 48 " Languages {{{ 45 49 call minpac#add('aklt/plantuml-syntax') " ftplugin 46 - call minpac#add('b4b4r07/vim-hcl') " ftplugin 47 50 call minpac#add('cespare/vim-toml') " ftplugin 48 51 call minpac#add('dag/vim-fish') " ftplugin 49 - call minpac#add('elixir-lang/vim-elixir') " ftplugin 52 + call minpac#add('hauleth/vim-elixir', {'branch': 'fix/encode-all-db-options'}) " ftplugin 50 53 call minpac#add('pangloss/vim-javascript') " ftplugin 51 54 call minpac#add('tpope/vim-cucumber') " ftplugin 52 55 call minpac#add('tpope/vim-scriptease', {'type': 'opt'}) " ftplugin ··· 62 65 call minpac#add('neovim/nvim-lspconfig') 63 66 " }}} 64 67 " Code manipulation {{{ 65 - call minpac#add('AndrewRadev/splitjoin.vim') 68 + call minpac#add('AndrewRadev/splitjoin.vim', {'rev': 'main'}) 66 69 call minpac#add('hauleth/sad.vim') 67 70 call minpac#add('tommcdo/vim-exchange') 68 71 call minpac#add('tommcdo/vim-lion') ··· 93 96 call minpac#add('https://gitlab.com/hauleth/smart.vim.git') 94 97 call minpac#add('reedes/vim-pencil') 95 98 call minpac#add('sgur/vim-editorconfig') " Required during startup 96 - call minpac#add('simnalamburt/vim-mundo') 99 + call minpac#add('mbbill/undotree') 97 100 call minpac#add('tpope/vim-characterize') 98 101 call minpac#add('tpope/vim-dadbod') 99 102 call minpac#add('tpope/vim-repeat') " autoload-only plugin
-8
vim/.config/nvim/autoload/utils.vim
··· 1 - func! utils#cleanup() abort 2 - let l:bufers = filter(getbufinfo({'buflisted':1}), {_, v -> !filereadable(v.name) && empty(v.windows)}) 3 - for buf in l:bufers 4 - exec 'bd '.buf.bufnr 5 - endfor 6 - 7 - return l:bufers 8 - endfunc
+17 -1
vim/.config/nvim/fnl/langclient.fnl
··· 1 1 (local {:buf-map bmap} (require :nvim)) 2 2 (local lsp (require :lspconfig)) 3 + (local utils (require :lspconfig.util)) 3 4 (local picker (require :picker)) 4 5 (import-macros logger :nvim.logger) 5 6 (import-macros {: bopt} :nvim.macros) 7 + 8 + (require :lspconfig.erlangls) 6 9 7 10 (fn capable? [client capability] 8 11 (. client.resolved_capabilities capability)) ··· 22 25 (when (capable? client :completion) 23 26 (bopt omnifunc "v:lua.vim.lsp.omnifunc"))) 24 27 25 - (lsp.elixirls.setup {:cmd ["nix-shell" "--show-trace" "--run" "elixir-ls"] 28 + (fn nix-cmd [name cmd] 29 + ["nix-shell" 30 + "-E" (.. "with import <nixpkgs> {}; with (if (builtins.pathExists ./shell.nix) then (import ./shell.nix {}).passthru else (import <nixpkgs> {})); mkShell { buildInputs = [" name "]; }") 31 + "--run" (or cmd name)]) 32 + 33 + (lsp.rust_analyzer.setup {:cmd (nix-cmd "rust-analyzer") 34 + :on_attach on-attach}) 35 + 36 + (lsp.elixirls.setup {:cmd (nix-cmd "elixir_ls" "elixir-ls") 26 37 :on_attach on-attach 27 38 :settings {:elixirLS {:dialyzerEnabled false}}}) 39 + 40 + (lsp.erlangls.setup {:cmd (nix-cmd "erlang-ls" "erlang_ls") 41 + :on_attach on-attach}) 42 + 43 + (lsp.solargraph.setup {:on_attach on-attach})
+13
vim/.config/nvim/fnl/lspconfig/erlangls.fnl.old
··· 1 + (local configs (require :lspconfig.configs)) 2 + (local util (require :lspconfig.util)) 3 + 4 + (fn root-dir [name] 5 + (let [root-pattern (util.root_pattern "rebar.config" ".git")] 6 + (or (root-pattern name) (vim.loop.os_homedir)))) 7 + 8 + (tset configs :erlangls { 9 + :default_config { 10 + :filetypes [:erlang] 11 + :root_dir root-dir 12 + } 13 + })
+20 -6
vim/.config/nvim/fnl/nvim/init.fnl
··· 41 41 (each [mode (modes:gmatch ".")] 42 42 (cb mode lhs normalised-rhs map-opts))))) 43 43 44 + 44 45 (local api (setmetatable {} 45 46 {:__index (fn [_ key] 46 47 (let [func (.. "nvim_" key)] 47 48 (. vim.api func)))})) 48 49 49 - (fn executable? [name] 50 - (api.call_function "executable" [name])) 50 + (local ex (setmetatable {} 51 + {:__index (fn [_ key] 52 + (fn [...] 53 + (api.command (.. key " " (table.concat [...] " ")))))})) 51 54 52 - (fn colorscheme [name] 53 - (api.command (.. "colorscheme " name))) 55 + (fn ?> [f ...] (let [(ok? val) (f)] (if ok? val (?> ...)))) 56 + 57 + (fn get-opt [key] 58 + (let [bo #(pcall api.buf_get_option 0 key) 59 + wo #(pcall api.win_get_option 0 key) 60 + go #(values true (api.get_option key))] 61 + (?> bo wo go))) 54 62 55 63 (fn call [name ...] 56 - (api.call_function name (or ... []))) 64 + (api.call_function name [...])) 65 + 66 + (fn executable? [name] 67 + (call :executable name)) 57 68 69 + ;; Exports 58 70 (setmetatable {:map (make-map api.set_keymap) 59 71 :buf-map (make-map #(api.buf_set_keymap 0 $...)) 72 + : api 73 + : ex 60 74 : call 61 - : colorscheme 62 75 : make-func 76 + : get-opt 63 77 : executable?} {:__index api})
+2 -1
vim/.config/nvim/fnl/nvim/macros.fnl
··· 20 20 (tset ,scope ,opt (if (= (. ,scope ,opt) "") v# (.. v# "," (. ,scope ,opt))))) 21 21 :+ `(let [v# ,value] 22 22 (tset ,scope ,opt (if (= (. ,scope ,opt) "") v# (.. (. ,scope ,opt) "," v#)))) 23 - _ `(tset ,scope ,opt ,(or value true))))) 23 + _ `(tset ,scope ,opt ,(if (= value nil) true value))))) 24 24 25 25 (fn opt [name value] 26 26 "Set Vim option" ··· 83 83 flags (translate-opts opts1)] 84 84 `(vim.api.nvim_command (.. "command! " ,flags " " ,(view name) " " ,command)))) 85 85 86 + ;; Exports 86 87 {: augroup 87 88 : defcommand 88 89 : env
+2 -1
vim/.config/nvim/fnl/picker.fnl
··· 14 14 (. (require :telescope.builtin) name)) 15 15 16 16 (fn find_files [opts] 17 - (let [defaults {:find_command ["rg" "--hidden" "--ignore" "--files" "--glob=!.git"]} 17 + (let [defaults {:find_command ["rg" "--hidden" "--ignore" "--files" "--glob=!.git" "--glob=!*.lock"] 18 + :previewer false} 18 19 options (vim.tbl_extend :force defaults (or opts {}))] 19 20 ((finder :find_files) options))) 20 21
+51 -35
vim/.config/nvim/fnl/startup.fnl
··· 1 1 (local {: map 2 - : call 3 2 : command 4 3 : executable? 5 - : colorscheme &as nvim} (require :nvim)) 4 + : call 5 + : api 6 + : get-opt 7 + : ex} (require :nvim)) 6 8 (local picker (require :picker)) 9 + (import-macros logger :nvim.logger) 7 10 (import-macros {: augroup 8 11 : defcommand 9 12 : on 10 13 : env 11 14 : g 12 15 : opt 16 + : bopt 13 17 : wopt} :nvim.macros) 14 18 15 19 ; Colors 16 - (colorscheme :blame) 20 + (ex.colorscheme :blame) 17 21 18 22 (opt shell "fish") 19 23 ··· 27 31 ; Indentation 28 32 (opt shiftwidth 2) 29 33 (opt expandtab) 34 + (bopt expandtab) 30 35 (opt textwidth 80) 31 36 (wopt wrap false) 32 37 (wopt linebreak) ··· 48 53 (opt wildignorecase) 49 54 (opt wildmode :full) 50 55 (opt fileignorecase) 51 - (opt wildignore "*.o,*~,**/.git/**,**/tmp/**,**/node_modules/**,**/_build/**,**/deps/**,**/target/**,**/uploads/**") 56 + (opt wildignore "*.o,*~,**/.git/**,**/tmp/**,**/node_modules/**,**/_build/**,**/deps/**,**/target/**,**/uploads/**,*.lock") 52 57 53 58 (opt diffopt+ "indent-heuristic,algorithm:patience") 54 59 (opt tags^ "./**/tags") ··· 138 143 (map :n :0 "virtcol('.') - 1 <= indent('.') && col('.') > 1 ? '0' : '_'" {:expr true}) 139 144 140 145 (map :n :gK ":Dash") 141 - (map :n :gq #(call :open#open)) 146 + (map :n :gq (fn [] 147 + (let [name (call :expand "<cfile>")] 148 + (call :jobstart ["open" name] {:detach true}) 149 + (print "Open" name)))) 142 150 143 151 ; Text object for whole file 144 152 (map :o :aG ":normal! ggVG") ··· 154 162 (map :n "<C-q>t" ":tabnew +term") 155 163 156 164 (map :t "<C-q>" "<C-\\><C-n>") 165 + (map :i "<C-q>" "<ESC>") 157 166 (map :n "<C-q>" "<ESC>") 158 167 159 168 (when (executable? "nvr") ··· 173 182 (git-map :g "log")) 174 183 175 184 ; Split management 176 - (augroup align-windows 177 - (on VimEnter "*" (command "wincmd ="))) 178 185 (map :n "<C-w><C-w>" "<plug>(choosewin)" {:noremap false}) 179 186 (map :n "<C-_>" "<plug>(choosewin)" {:noremap false}) 180 187 ··· 188 195 189 196 (augroup matchparen 190 197 (let [term "term://*"] 191 - (on BufEnter term (command "NoMatchParen")) 192 - (on BufLeave term (command "DoMatchParen")))) 198 + (on BufEnter term (ex.NoMatchParen)) 199 + (on BufLeave term (ex.DoMatchParen)))) 193 200 194 201 ; Autoreload Direnv after writing the .envrc 195 202 (when (executable? "direnv") 196 203 (augroup autoreload-envrc 197 - (on BufWritePost ".envrc" (command "silent !direnv allow %")))) 198 - 199 - ; Clean non-existing buffers on leave 200 - (augroup autoclean 201 - (on BufLeave "*" (call :utils#cleanup))) 204 + (on BufWritePost ".envrc" (ex.silent "!direnv allow %")))) 202 205 203 206 ; Setup Lua extensions 204 207 (let [setup (fn [package object] ((. (require package) :setup) object))] 205 208 (setup :nvim-treesitter.configs 206 - {:ensure_installed :maintained 207 - :highlight {:enable true} 209 + {:ensure_installed [:erlang 210 + :elixir 211 + :nix 212 + :typescript 213 + :javascript 214 + :c 215 + :json 216 + :fennel 217 + :html 218 + :css 219 + :yaml 220 + :rust 221 + :toml] 222 + :highlight {:enable true 223 + ; :disable [:elixir] 224 + } 208 225 :indent {:enable true}}) 209 226 (setup :startify 210 227 {:lists [{:type "sessions" :header [" Sessions"]} ··· 232 249 (call :plugins#reload) 233 250 (call :minpac#status)) 234 251 235 - (defcommand Term "<mods> split +term | startinsert") 236 252 (defcommand Bd "b#|bd#") 253 + (defcommand BClean 254 + (->> (call :getbufinfo {:buflisted true}) 255 + (vim.tbl_filter #(= (next $1.windows) nil)) 256 + (#(each [_ v (ipairs $1)] 257 + (command (.. "bd " v.bufnr)))))) 237 258 (defcommand Clean "keeppatterns %s/\\s\\+$//e | set nohlsearch") 238 259 239 260 ; Async Make and Grep 240 261 (let [run (fn [args f-args] 241 - (nvim.call_function :asyncdo#run (vim.list_extend args f-args)))] 262 + (api.call_function :asyncdo#run (vim.list_extend args f-args)))] 242 263 (defcommand Make {:bang true :nargs :* :complete :file} 243 - (run [bang vim.o.makeprg] f-args)) 264 + (run [bang (get-opt :makeprg)] f-args)) 244 265 (defcommand Grep {:bang true :nargs :+ :complete :dir} 245 - (run [bang {:job vim.o.grepprg :errorformat vim.o.grepformat}] f-args))) 266 + (run [bang {:job (get-opt :grepprg) :errorformat (get-opt :grepformat)}] f-args))) 246 267 247 - ; Async LMake and LGrep 248 - (let [run (fn [args f-args] 249 - (nvim.call_function :asyncdo#lrun (vim.list_extend args f-args)))] 250 - (defcommand LMake {:bang true :nargs :* :complete :file} 251 - (run [bang vim.o.makeprg] f-args)) 252 - (defcommand LGrep {:bang true :nargs :+ :complete :dir} 253 - (run [bang {:job vim.o.grepprg :errorformat vim.o.grepformat}] f-args))) 254 - 255 - (defcommand Ctags (command :AsyncDo "ctags -R .")) 268 + (defcommand Ctags 269 + (command :AsyncDo "ctags -R .")) 256 270 (defcommand Start {:nargs :*} 257 - (command (.. mods " split new")) 258 - (call :termopen q-args) 259 - (command :startinsert)) 260 - (defcommand Dash {:nargs :?} (call :dash#open q-args)) 271 + (let [cmd (call :expand q-args)] 272 + (command (.. mods " new")) 273 + (call :termopen cmd) 274 + (ex.startinsert))) 275 + (defcommand Dash {:nargs :?} 276 + (call :dash#open q-args)) 261 277 262 278 (do 263 - (command "packadd! vim-sandwich") 264 - (command "runtime macros/sandwich/keymap/surround.vim")) 279 + (ex.packadd! :vim-sandwich) 280 + (ex.runtime "macros/sandwich/keymap/surround.vim")) 265 281 266 282 (require :startify) 267 283 (require :langclient)
-5
vim/.config/nvim/init.lua
··· 23 23 end 24 24 fennel.path = fennel.path .. fennel_paths 25 25 26 - local u = require('utils') 27 - 28 26 require('startup') 29 - 30 - -- Load legacy configuration file 31 - vim.api.nvim_command('runtime! legacy.vim')
+12
vim/.config/nvim/lua/lspconfig/erlangls.lua
··· 1 + local configs = require 'lspconfig/configs' 2 + local util = require 'lspconfig/util' 3 + 4 + local server_name = 'erlangls' 5 + configs[server_name] = { 6 + default_config = { 7 + filetypes = {'erlang'}, 8 + root_dir = function(fname) 9 + return util.root_pattern('rebar.config', '.git')(fname) or vim.loop.os_homedir() 10 + end 11 + } 12 + }
-52
vim/.config/nvim/lua/utils.lua
··· 1 - local function tbl_filter(func, t) 2 - vim.validate{func={func,'c'},t={t,'t'}} 3 - 4 - local rettab = {} 5 - for key, entry in pairs(t) do 6 - if func(key, entry) then 7 - rettab[key] = entry 8 - end 9 - end 10 - return rettab 11 - end 12 - 13 - local function normalise_map(rhs, opts) 14 - -- If it is command line map, then automaticall add <C-u> for cleaning 15 - -- selection and <CR> at the end, to fire it up 16 - if vim.startswith(rhs, ':') and rhs ~= ':' then 17 - if not vim.startswith(rhs, ':<C-u>') and options["selection"] then 18 - rhs = '<cmd>' .. rhs:sub(2) 19 - end 20 - if not vim.endswith(rhs, '<CR>') and options["cr"] then 21 - rhs = rhs .. '<CR>' 22 - end 23 - end 24 - 25 - return rhs 26 - end 27 - 28 - local function do_map(cb) 29 - return function(modes, lhs, rhs, opts) 30 - -- Defaults to non recursive mappings 31 - options = vim.tbl_extend('force', {noremap = true, selection = true, cr = true}, opts or {}) 32 - 33 - if modes == '' then 34 - error('Modes must not be empty') 35 - end 36 - 37 - local f = function(k, _) 38 - return not (k == "selection" or k == "cr") 39 - end 40 - local map_opts = tbl_filter(f, options) 41 - local normalised = normalise_map(rhs, options) 42 - 43 - for mode in modes:gmatch('.') do 44 - cb(mode, lhs, normalised, map_opts) 45 - end 46 - end 47 - end 48 - 49 - return { 50 - map = do_map(vim.api.nvim_set_keymap), 51 - buf_map = do_map(function(...) vim.api.nvim_buf_set_keymap(0, ...) end) 52 - }
+1
vim/.config/nvim/plugin/statusline.vim
··· 6 6 let &statusline .= '%#StatusLineNC#%{statusline#path()}%*' 7 7 let &statusline .= '%=' 8 8 let &statusline .= '%{FugitiveHead()} %{statusline#quickfix()} %4c:%l' 9 + " let &statusline .= '%{statusline#quickfix()} %4c:%l'
+3 -5
vim/.config/nvim/plugin/wiki.vim
··· 1 - let g:vimwiki_list = [{'path': '~/Documents/Wiki/'}] 2 - let g:vimwiki_key_mappings = 3 - \ { 4 - \ 'headers': 0, 5 - \ } 1 + let g:vimwiki_list = [{'path': '~/Documents/Wiki/', 'ext': '.wiki'}] 2 + 3 + let g:vimwiki_key_mappings = { 'headers': 0 } 6 4 7 5 nnoremap <C-b><C-b> :<C-u>split +VimwikiIndex<CR> 8 6 nnoremap <C-b>t :<C-u>split +VimwikiTabIndex<CR>