diff --git a/home/profiles/nvim/config/fnl/conf/formatting.fnl b/home/profiles/nvim/config/fnl/conf/formatting.fnl index e69de29b..bbfc9a76 100644 --- a/home/profiles/nvim/config/fnl/conf/formatting.fnl +++ b/home/profiles/nvim/config/fnl/conf/formatting.fnl @@ -0,0 +1,11 @@ +(import-macros {: do-req } :lib/macros) + +(do-req :conform :setup + {:formatters_by_ft {:lua ["stylua"] + :nix ["nixfmt"] + ; :go ["goimports" "gofmt"] ; Go handled in special case + :terraform ["terraform_fmt"] + :sh ["shfmt"] + :bazel ["buildifier"]} + :format_on_save {:lsp_format "fallback" + :timeout_ms 500}}) diff --git a/home/profiles/nvim/config/fnl/conf/init.fnl b/home/profiles/nvim/config/fnl/conf/init.fnl index 2408d1f3..be0765f6 100644 --- a/home/profiles/nvim/config/fnl/conf/init.fnl +++ b/home/profiles/nvim/config/fnl/conf/init.fnl @@ -25,7 +25,6 @@ (nvim.opt :signcolumn "yes") (nvim.opt :cursorline true) - (nvim.opt :lisp true) ; include - in word to move better in snake-case) (nvim.g :sexp_filetypes "clojure,scheme,lisp,janet,fennel,yuck") ; include the lisps I use @@ -36,5 +35,13 @@ (require :conf.mappings) (require :conf.lsp) (require :conf.plugins.cmp) -; (require :conf.formatting) +(require :conf.formatting) ; (require :conf.kitaab) + +; Spelling +(vim.api.nvim_create_autocmd ["BufRead" "BufNewFile"] + {:pattern ["*.wiki" "*.txt" "*.md" "*.tex"] + :command "setlocal spell"}) +(vim.api.nvim_create_autocmd ["FileType"] + {:pattern ["mail"] + :command "setlocal spell"}) diff --git a/home/profiles/nvim/config/fnl/conf/lsp.fnl b/home/profiles/nvim/config/fnl/conf/lsp.fnl index db20ecab..6cce7f44 100644 --- a/home/profiles/nvim/config/fnl/conf/lsp.fnl +++ b/home/profiles/nvim/config/fnl/conf/lsp.fnl @@ -1,10 +1,31 @@ -; (local lspfuzzy (require :lspfuzzy)) +(import-macros {: do-req } :lib/macros) (local lspkind (require :lspkind)) (local lspconfig (require :lspconfig)) +(local lspsaga (require :lspsaga)) (local cmp (require :cmp)) (local nvim (require :lib/nvim)) +; (local lspfuzzy (require :lspfuzzy)) ; (local sg (require :sg)) ; (local lsputil (require :lspconfig/util)) +; (local navic (require :nvim-navic)) + +(lspsaga.setup {:border_style "rounded" + :code_action_icon "" + :code_action_num_shortcut true + :code_action_lightbulb { + :enable false + } + ; show outline + :show_outline { + :win_position "right" + :auto_enter true + :auto_preview true + :virt_text "┃" + :jump_key "o" + ; auto refresh when change buffer + :auto_refresh true + } + }) (tset vim.lsp.handlers :textDocument/hover @@ -47,7 +68,7 @@ {:capabilities capabilities :codelens {:generate true :gc_details true} :semanticTokens true - :flags { :debounce_text_changes 200} + :flags {:debounce_text_changes 200} :analyses {:unusedparams true :unusedvariables true :unusedwrite true @@ -66,53 +87,14 @@ :rangeVariableTypes true} :on_attach on-attach}) +(local lsps [:nil_ls :terraform_lsp :fennel_ls :tsserver]) +(each [index lsp (ipairs lsps)] + ((. (. lspconfig lsp) :setup) {})) -; # local servers = { 'clojure_lsp', 'terraform_lsp', 'zls', 'pyright', 'rust_analyzer', 'tsserver', 'lua_ls', 'nil_ls', 'gopls'} -; # for _, lsp in ipairs(servers) do -; # lspconfig[lsp].setup {} -; # on_attach = function(client, bufnr) -; # format.on_attach(client) -; # navic.attach(client, bufnr) -; # end, -; # capabilities = capabilities, -; # -; # end) -;; Diagnostics Config I don't yet understand -; Set Diagnostics -; local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } -; for type, icon in pairs(signs) do -; local hl = "DiagnosticSign" .. type -; vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl}) -; end +; null-ls +(let [null-ls (require :null-ls)] + (null-ls.setup {:sources [;null-ls.builtins.diagnostics.shellcheck + null-ls.builtins.diagnostics.commitlint]})) + ;null-ls.builtins.diagnostics.jsonlint]})) + ;(null-ls.builtins.diagnostics.proselint.with {:filetypes ["vimwiki" "mail"]})]})) -; vim.g.diagnostics_active = true -; function _G.toggle_diagnostics() -; if vim.g.diagnostics_active then -; vim.g.diagnostics_active = false -; vim.lsp.diagnostic.clear(0) -; vim.lsp.handlers["textDocument/publishDiagnostics"] = function() end -; else -; vim.g.diagnostics_active = true -; vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( -; vim.lsp.diagnostic.on_publish_diagnostics, { -; virtual_text = true, -; signs = true, -; underline = true, -; update_in_insert = false, -; } -; ) -; end -; end -; -; vim.diagnostic.config({ -; signs = true, -; update_in_insert = false, -; underline = false, -; severity_sort = true, -; float = { -; focusable = false, -; style = 'minimal', -; border = 'rounded', -; source = 'always', -; }, -; }) diff --git a/home/profiles/nvim/config/fnl/conf/mappings.fnl b/home/profiles/nvim/config/fnl/conf/mappings.fnl index 97633298..6c38cd5a 100644 --- a/home/profiles/nvim/config/fnl/conf/mappings.fnl +++ b/home/profiles/nvim/config/fnl/conf/mappings.fnl @@ -1,4 +1,6 @@ (local nvim (require :lib/nvim)) +(import-macros {: do-req } :lib/macros) + (local wk (require :which-key)) ;; Convenient way to indent stuff in visual mode @@ -30,8 +32,13 @@ (nvim.keymap [:n] "gt" ":BufferNext" {:silent true :noremap true}) (nvim.keymap [:n] "gj" ":BufferPick" {:silent true :noremap true}) (nvim.keymap [:n] "gb" ":Telescope buffers" {:silent true :noremap true}) -(nvim.keymap [:n] "gq" ":BufferClosoe" {:silent true :noremap true}) +(nvim.keymap [:n] "gq" ":BufferClose" {:silent true :noremap true}) +; Flash +(vim.api.nvim_create_user_command "Flash" (fn [_] (do-req :flash :jump)) {}) +(vim.api.nvim_create_user_command "FlashTreesitter" (fn [] (do-req :flash :treesitter)) {}) +(nvim.keymap [:n] "f" "Flash") +(nvim.keymap [:n] "s" "FlashTreesitter") (local normal-map-leader @@ -111,9 +118,10 @@ "Rename Symbol"] :h [":Lspsaga hover_doc" "Hover doc"] - :o [":LSoutlineToggle" + :o ["AerialToggle!" "Outline"] - :t [":call v:lua.toggle_diagnostics()"]} + :t [":LspDiagnostics 0" + "Find Errors in Buffer"]} ; Kitaab "z" {:name "Kitaab" :n [":ZettelNew" diff --git a/home/profiles/nvim/config/fnl/conf/music.fnl b/home/profiles/nvim/config/fnl/conf/music.fnl index 81136de1..28d3065e 100644 --- a/home/profiles/nvim/config/fnl/conf/music.fnl +++ b/home/profiles/nvim/config/fnl/conf/music.fnl @@ -2,3 +2,29 @@ (nvim.g :tidal_target "terminal") (nvim.g :scnvim_snippet_format "luasnip") + +; -- supercollider +; local scnvim = require 'scnvim' +; local map = scnvim.map +; local map_expr = scnvim.map_expr +; scnvim.setup { +; keymaps = { +; ['e'] = map('editor.send_line', {'i', 'n'}), +; ['s'] = map_expr('CmdPeriod.run', {'i', 'n'}), +; ['t'] = { +; map('editor.send_block', {'i', 'n'}), +; map('editor.send_selection', 'x'), +; }, +; [''] = map('postwin.toggle'), +; [''] = map('postwin.toggle', 'i'), +; [''] = map('postwin.clear', {'n', 'i'}), +; [''] = map('signature.show', {'n', 'i'}), +; [''] = map('sclang.hard_stop', {'n', 'x', 'i'}), +; ['st'] = map('sclang.start'), +; ['sk'] = map('sclang.recompile'), +; [''] = map_expr('s.boot'), +; [''] = map_expr('s.meter'), +; } +; } +; -- You gotta run :SCNvimGenerateAssets for this first +; -- require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets()) diff --git a/home/profiles/nvim/config/fnl/conf/plugins.fnl b/home/profiles/nvim/config/fnl/conf/plugins.fnl index 9b9ef6f1..e165437d 100644 --- a/home/profiles/nvim/config/fnl/conf/plugins.fnl +++ b/home/profiles/nvim/config/fnl/conf/plugins.fnl @@ -1,13 +1,14 @@ (local nvim (require :lib/nvim)) - (local navic (require :nvim-navic)) +(import-macros {: do-req } :lib/macros) + (let [lualine (require :lualine)] (lualine.setup {:options {:theme "ayu"} :sections {:lualine_c [:filename {1 navic.get_location :cond navic.is_available}] :lualine_y [(fn [] - ; TODO broken? + ; TODO broken (let [msg "No Active Lsp" buf_ft (vim.api.nvim_buf_get_option 0 "filetype") clients (vim.lsp.get_active_clients)] @@ -19,3 +20,25 @@ :lualine_x [:filetype]}})) (require :neo-tree) +(do-req :gitsigns :setup) +(do-req :marks :setup) +(do-req :mini.pairs :setup) +(do-req :mini.diff :setup) +(do-req :mini.ai :setup) +;TODO (do-req :mini.surround :setup) +(do-req :todo-comments :setup) +(do-req :ibl :setup) + +(do-req :nvim-treesitter.configs :setup {:highlight {:enable true} + :textobjects {:enable true} + :indent {:enable true}}) +(do-req :treesitter-context :setup {:max_lines 5}) + +(do-req :auto-session :setup {:log_level "info" + :auto_session_suppress_dirs ["~/"]}) +(nvim.opt :sessionoptions "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal") + +(do-req :aerial :setup {:on_attach (fn [bufnr] + (do + (vim.keymap.set "n" "{" "AerialPrev" { :buffer bufnr}) + (vim.keymap.set "n" "}" "AerialNext" { :buffer bufnr})))}) diff --git a/home/profiles/nvim/config/fnl/conf/plugins/cmp.fnl b/home/profiles/nvim/config/fnl/conf/plugins/cmp.fnl index 0ccead0c..51a60d5f 100644 --- a/home/profiles/nvim/config/fnl/conf/plugins/cmp.fnl +++ b/home/profiles/nvim/config/fnl/conf/plugins/cmp.fnl @@ -11,47 +11,21 @@ (= (: (: cur-line :sub col col) :match "%s") nil)))) -(fn tab [fallback] - (let [cmp (require :cmp) - luasnip (require :luasnip)] - (if (cmp.visible) - (cmp.select_next_item) - (let [available (luasnip.expand_or_jumpable)] - (if (= (available) true) - (luasnip.expand_or_jump) - (if (has-words-before) - (cmp.complete) - (fallback))))))) - -(fn stab [fallback] - (let [cmp (require :cmp) - luasnip (require :luasnip)] - (if (cmp.visible) - (cmp.select_prev_item) - (let [available (luasnip.jumpable -1)] - (if (= (available) true) - (luasnip.jump -1) - (if (has-words-before) - (cmp.complete) - (fallback))))))) - -(let [lspkind (require :lspkind) - luasnip_loaders (require :luasnip.loaders.from_vscode)] - (luasnip_loaders.lazy_load) - (cmp.setup {:formatting {:format lspkind.cmp_format} - :snippet {:expand (fn [args] - (let [luasnip (require :luasnip)] - (luasnip.lsp_expand args.body)))} +(let [lspkind (require :lspkind)] + (cmp.setup {:formatting {:format lspkind.cmp_format + :show_labelDetails true} + ;:snippet {:expand (fn [args] + ; (let [luasnip (require :luasnip)] + ; (luasnip.lsp_expand args.body)) :sources [{:name "buffer"} {:name "nvim_lsp"} {:name "look"} {:name "path"} {:name "calc"} {:name "spell"} - {:name "cmp-conjure"} {:name "luasnip"} {:name "tags"}] :mapping {"" (cmp.mapping.scroll_docs -4) "" (cmp.mapping.scroll_docs 4) "" (cmp.mapping (cmp.mapping.select_prev_item) [:i :c]) "" (cmp.mapping (cmp.mapping.select_next_item) [:i :c]) "" (cmp.mapping.close) - "" (cmp.mapping.confirm {:select true}) - "" (cmp.mapping tab [:i :s]) - "" (cmp.mapping stab [:i :s])}})) + "" (cmp.mapping.confirm {:select true})}})) + ; "" (cmp.mapping tab [:i :s]) + ; "" (cmp.mapping stab [:i :s])}})) diff --git a/home/profiles/nvim/config/fnl/conf/plugins/kitaab.fnl b/home/profiles/nvim/config/fnl/conf/plugins/kitaab.fnl index 990752e1..fc8bfea4 100644 --- a/home/profiles/nvim/config/fnl/conf/plugins/kitaab.fnl +++ b/home/profiles/nvim/config/fnl/conf/plugins/kitaab.fnl @@ -1,5 +1,10 @@ +; Kitaab is why I'm so tied to vim. +; If only I could find a nice notes editor... + (local nvim (require :lib/nvim)) +(import-macros {: do-req } :lib/macros) + (nvim.g :vimwiki_list [{:path "~/kitaab/vimwiki" :auto_tags 1 :auto_diary_index 1 @@ -9,3 +14,22 @@ :nix "nix" :bash "sh"}}]) (nvim.g :zettel_format "%y%m%d-%H%M") + +; Custom functions +(fn update_date [] + (var written false) + (let [time (os.date "%Y-%m-%d %H:%M") + message (.. "%update " time) + lines (vim.api.nvim_buf_get_lines 0 0 4 false)] + (each [index line (ipairs lines)] + (if (and (= (length line) 0) (not written)) + (do + (vim.api.nvim_buf_set_lines 0 (- index 1) index false [message ""]) + (set written true))) + (if (and (= index 4) (not written)) + (vim.api.nvim_buf_set_lines 0 3 index false [message]))))) + +(vim.api.nvim_create_autocmd "BufWritePre" {:pattern ["*.wiki"] + :callback update_date}) + +(do-req :hologram :setup {:auto_display false}) diff --git a/home/profiles/nvim/config/fnl/lib/macros.fnl b/home/profiles/nvim/config/fnl/lib/macros.fnl new file mode 100644 index 00000000..9985c153 --- /dev/null +++ b/home/profiles/nvim/config/fnl/lib/macros.fnl @@ -0,0 +1,6 @@ +(fn do-req [mod key ...] + `(let [name# (require ,mod) + fun# (. name# ,key)] + (fun# ,...))) + +{: do-req} diff --git a/home/profiles/nvim/default.nix b/home/profiles/nvim/default.nix index 69d16bc6..f99fbb90 100644 --- a/home/profiles/nvim/default.nix +++ b/home/profiles/nvim/default.nix @@ -22,6 +22,7 @@ { home.sessionVariables.EDITOR = "nvim"; home.shellAliases = { + vim = "nvim"; k = "cd ~/kitaab/vimwiki; vim -c :VimwikiIndex; cd $OLDPWD"; # kitaab zettel kz = "cd ~/kitaab/vimwiki; vim -c :VimwikiIndex -c :ZettelNew; cd $OLDPWD"; @@ -48,7 +49,6 @@ # filetype plugin on # set shortmess+=c - # " always show signcolumns # " Pasting # :map sy :!xclip -i @@ -59,22 +59,8 @@ # lua <e'] = map('editor.send_line', {'i', 'n'}), - # ['s'] = map_expr('CmdPeriod.run', {'i', 'n'}), - # ['t'] = { - # map('editor.send_block', {'i', 'n'}), - # map('editor.send_selection', 'x'), - # }, - # [''] = map('postwin.toggle'), - # [''] = map('postwin.toggle', 'i'), - # [''] = map('postwin.clear', {'n', 'i'}), - # [''] = map('signature.show', {'n', 'i'}), - # [''] = map('sclang.hard_stop', {'n', 'x', 'i'}), - # ['st'] = map('sclang.start'), - # ['sk'] = map('sclang.recompile'), - # [''] = map_expr('s.boot'), - # [''] = map_expr('s.meter'), - # } - # } - # -- You gotta run :SCNvimGenerateAssets for this first - # -- require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets()) # -- zen mode # require('zen-mode').setup{ @@ -347,10 +217,6 @@ # } # require('twilight').setup{} - # -- hologram - # require('hologram').setup{ - # auto_display = false -- WIP automatic markdown image display, may be prone to breaking - # } # EOF @@ -358,19 +224,20 @@ extraPackages = with pkgs; [ # used to compile tree-sitter grammar # python-with-my-packages - nodejs - clojure-lsp - clojure - clj-kondo + # nodejs + # clojure-lsp + # clojure + # clj-kondo terraform-lsp + nil gopls gcc shellcheck proselint - statix - nodePackages.typescript - nodePackages.typescript-language-server - luajitPackages.lua-lsp + # statix + # nodePackages.typescript + # nodePackages.typescript-language-server + # luajitPackages.lua-lsp fennel-ls # starpls-bin # TODO find this!! ]; @@ -386,33 +253,32 @@ nvim-web-devicons telescope-nvim plenary-nvim - nvim-navic FTerm-nvim barbar-nvim - - # TODO - # neotree neovim-ayu rainbow_parentheses-vim - vim-surround - undotree - - (nvim-treesitter.withPlugins (p: [ p.nix p.clojure p.fennel p.lua p.html p.css p.regex p.supercollider p.beancount p.markdown p.glsl p.yaml p.toml p.dockerfile p.json ])) - nvim-treesitter-context auto-session which-key-nvim - zen-mode-nvim - twilight-nvim - - # TODO remove? - vim-dasht + aerial-nvim + todo-comments-nvim + indent-blankline-nvim + + # Tree sitter + (nvim-treesitter.withPlugins (p: [ p.nix p.clojure p.fennel p.lua p.html p.css p.regex p.supercollider p.beancount p.markdown_inline p.markdown p.glsl p.yaml p.toml p.dockerfile p.json p.go ])) + nvim-treesitter-context + nvim-treesitter-textobjects + + # TODO + nvim-navic + undotree + marks-nvim # language vim-nix emmet-vim csv-vim direnv-vim - conjure + # conjure # kitaab stuff vimwiki @@ -420,24 +286,20 @@ hologram-nvim # lsp stuff - # nvim-lint - null-ls-nvim nvim-lspconfig nvim-cmp cmp-nvim-lsp cmp-treesitter - nvim-lsp-ts-utils - lspsaga-nvim - cmp-conjure + # cmp-conjure cmp-buffer cmp-path cmp-spell - nvim-autopairs - cmp_luasnip - luasnip - lsp-format-nvim - friendly-snippets lspkind-nvim + conform-nvim + none-ls-nvim + mini-nvim + lspsaga-nvim + # nvim-lspfuzzy # git stuff vim-fugitive @@ -454,7 +316,7 @@ # experimental nvim-luapad scnvim - leap-nvim + flash-nvim vim-beancount # vimtex # custom