123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- (import-macros {: for!} :macros)
- (local {: ?->table : extend : textend : compose : elem
- : filter} (require :utils))
- (local extend-unpack (compose (. (require :utils.pure) :extend) unpack))
- (local textend-unpack (compose textend unpack))
- (local NO-FT :-NO-FT-)
- (λ ft-opt-config-fts [config]
- (icollect [ft cfg (pairs config)]
- (if (= :number (type ft))
- cfg
- ft)))
- (λ ft-config-fts [config]
- "get fts from table with keys: string|string[]"
- (extend-unpack
- (icollect [ft _ (pairs config)]
- (?->table ft))))
- (λ ft-config-cfgs [config]
- "get cfgs from table with values: string|string[]"
- (extend-unpack
- (icollect [_ cfg (pairs config)]
- (?->table cfg))))
- (λ lsp-find [lsp-cfg ft]
- "return list of lsp servers for file type"
- (local unp
- (let [unp []]
- (each [fts lsp (pairs lsp-cfg)]
- (for! ft (?->table fts)
- (tset unp ft lsp)))
- unp))
- (match unp
- {ft lsps} (?->table lsps)))
- (local neogit
- [:NeogitCommitMessage
- :NeogitCommitView
- :NeogitGitCommandHistory
- :NeogitLog
- :NeogitLogView
- :NeogitNotification
- :NeogitPopup
- :NeogitStatus])
- (local telescope
- [:TelescopeResults :TelescopePrompt])
- (local not-code
- [:qf :man :help :startify :packer :Trouble :vimwiki :lspinfo])
- (local formaters
- #(textend
- [:sh :zsh :haskell :rust :ebuild]
- {:python [:autopep8 :yapf]
- :markdown :mdformat
- :haskell :brittany}))
- (local lsp-cfg
- ;; fts ;; lsps ;;
- {:haskell "hls"
- ; :nim "nimls"
- :zig "zls"
- :python "pylsp"
- :purescript "purescriptls"
- :html ["html"] ; "emmet_language_server"]
- [:css :scss :sass] ["cssls" "emmet_language_server"]
- [:typescript :javascript] "denols"
- [:c :cpp] "clangd"
- :rust "rust_analyzer"})
- (local linters
- {[:c :cpp] "clangtidy"
- :sh "shellcheck"})
- (local ts-cfg
- #(textend
- {:sh "bash"
- :fasm "asm"
- :dosini "ini"
- :tex "latex"
- :help "vimdoc"
- NO-FT "regex"
- NO-FT "markdown_inline"}
- [:c
- :cpp
- :lua
- :vim
- :nim
- :hare
- :bash
- :make
- :norg
- :dhall
- :purescript
- :html
- :json
- :rust
- :zig
- :markdown
- :javascript
- :typescript
- :python
- :java
- :yaml
- :fennel
- :haskell]))
- (macro *gen-workspaces* [prefix ...]
- (let [form `(doto [])
- {: insert} table]
- (each [_ i (ipairs [...])]
- (insert form `(tset ,i ,(.. prefix i))))
- form))
-
- {:ts-parsers #(ft-config-cfgs (ts-cfg))
- :ts-fts #(filter #(not= NO-FT $) (ft-opt-config-fts (ts-cfg)))
- :lsp-fts #(ft-config-fts lsp-cfg)
- :lsp-lsps #(ft-config-cfgs lsp-cfg)
- :lsp-find (partial lsp-find lsp-cfg)
- : lsp-cfg
- ; :not-code (extend not-code neogit telescope)
- : formaters
- :format-fts #(ft-opt-config-fts (formaters))
- :format-key "<M-f>"
- :lisps [:lisp :fennel :hy :lissp]
- :linters-fts #(ft-config-fts linters)
- :linters-by-ft
- #(let [ret []]
- (each [fts l (pairs linters)]
- (for! ft (?->table fts)
- (tset ret ft (?->table l))))
- ret)
- :spell "en_us,ru_ru"
- :neorg-workspaces
- (textend
- {:tmp (let [{: TMPDIR} (require :xdg)] (.. (TMPDIR) :/neorg))}
- (*gen-workspaces* "~/Documents/NORG/"
- :wiki
- :notes
- :lists
- :etsy
- :vds
- :recipes
- :TODO
- :shop
- :projects
- :work))
- :template
- {:dir
- #(let [{: XDG_CONFIG_HOME} (require :xdg)
- {: path-sep} (require :utils.vim)]
- (.. (XDG_CONFIG_HOME) (path-sep) :templates.nvim))
- :prefix "auto"
- :ft [:c :python :dockerfile :sh :html]}}
|