Compare commits

..

1 Commits

6 changed files with 116 additions and 166 deletions

View File

@ -1,7 +1,7 @@
;;; macros.fnl - useful macros
;; Helpful keymaping functions
(lambda bind! [modes key cmd ?a1 ?a2]
(lambda bind! [mode key cmd ?a1 ?a2]
(let [desc (or ?a2 ?a1)
buf (if (and ?a1 ?a2) ?a1 ?a2)
opts { :noremap true
@ -9,12 +9,7 @@
:buffer buf }]
(when desc
(tset opts :desc desc))
(if (table? modes)
(let [output {}]
(each [_ mode (ipairs modes)]
(table.insert output `(vim.keymap.set ,mode ,key ,cmd ,opts)))
output)
`(vim.keymap.set ,modes ,key ,cmd ,opts))))
`(vim.keymap.set ,mode ,key ,cmd ,opts)))
;; Better autocommands
(lambda hook! [hooks ?patterns callback]
@ -26,7 +21,7 @@
(= (type ?patterns) :table)
?patterns
[ ?patterns ])]
(var group (.. (tostring (math.random 0 1000000000) "-config-hook")))
(var group "config-hook")
(each [_ hook (ipairs hook_table)]
(set group (.. group "-" hook)))
(each [_ pattern (ipairs pattern_table)]
@ -88,8 +83,7 @@
`(use ,output))
;; Call a plugin's `setup function'
(lambda setup! [pkg ...]
(local output [ ])
(lambda setup! [pkg ...] (local output [ ])
(var last_key nil)
(each [_ val (ipairs [...])]
(if last_key

View File

@ -12,12 +12,6 @@
;; tangerine.nvim (auto fennel compile)
(use! :udayvir-singh/tangerine.nvim)
;; hy syntax
(use! :hylang/vim-hy)
;; rainbow delimiters
(use! :HiPhish/rainbow-delimiters.nvim)
;; Treesitter
(use! :nvim-treesitter/nvim-treesitter
:config
@ -47,7 +41,14 @@
:config
(setup! :lualine
:options { :section_separators ""
:component_separators "│" }))
:component_separators "│" }
; :sections { :lualine_x [
; { 1 #(.. "recording @" (vim.fn.reg_recording))
; :cond #(not= (# (vim.fn.reg_recording)) 0) }
; :encoding
; :fileformat
; :filetype ]}
))
;; bufferline.nvim
(use! :akinsho/bufferline.nvim
@ -61,15 +62,13 @@
:show_buffer_close_icons false
:show_close_icon false }))
(use! :nvim-lua/plenary.nvim
:opt true
:module :plenary)
;; telescope (a fuzzy finder)
(use! :nvim-telescope/telescope.nvim
:cmd :Telescope
:module :telescope
:requires [ { 1 :nvim-telescope/telescope-ui-select.nvim
:requires [ { 1 :nvim-lua/plenary.nvim
:opt true }
{ 1 :nvim-telescope/telescope-ui-select.nvim
:opt true }
{ 1 :nvim-telescope/telescope-fzf-native.nvim
:opt true
@ -85,7 +84,6 @@
:TroubleToggle
:TroubleClose
:TroubleRefresh ]
:module :trouble
:config
(setup! :trouble))
@ -121,6 +119,22 @@
:config
(setup! :Comment))
;; nvim-find-other
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
:config
(setup! :nvim-find-other
:c [ "h" "H" ]
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
:tpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
:hpp [ "cpp" "tpp" "cxx" "c++" "cc" ])
(let [find-other (require :nvim-find-other)]
(vim.api.nvim_create_user_command
"FindOtherFile"
find-other.find_other_current_buffer
{})
(bind! :n :go find-other.find_other_current_buffer)))
;; illuminate (same symbol highlight)
(use! :RRethy/vim-illuminate
:config
@ -140,6 +154,18 @@
:IlluminatedWordText
{})))
;; vlime (lisp environment)
(use! :vlime/vlime
:ft :lisp
:config
(set vim.g.vlime_cl_impl :my_sbcl)
(set vim.g.vlime_address [ "127.0.0.1" 52842 ])
(vim.cmd "function! VlimeBuildServerCommandFor_my_sbcl(vlime_loader, vlime_eval)
return [ \"/usr/bin/sbcl\",
\\ \"--load\", a:vlime_loader,
\\ \"--eval\", \"(vlime:main :port 52842)\" ]
endfunction"))
;; Snippy
(use! :dcampos/nvim-snippy
:config
@ -153,6 +179,7 @@
:hrsh7th/cmp-path
:hrsh7th/cmp-cmdline
:hrsh7th/cmp-nvim-lsp
:HiPhish/nvim-cmp-vlime
{ 1 :ray-x/cmp-treesitter
:after :nvim-cmp }
:dcampos/cmp-snippy ]
@ -175,21 +202,42 @@
:setup
(bind! :n :<leader>p #(module-call! :nabla :popup)))
; oil (file manager)
(use! :stevearc/oil.nvim
:config
(setup! :oil
:columns [ :icon :permissions :size: :mtime ]))
;; guess style from buffer
(use! :NMAC427/guess-indent.nvim
:config
(setup! :guess-indent :auto_cmd true))
;(use! :edluffy/hologram.nvim
; :config
; (setup! :hologram
; :auto_display true))
;; formatter
(use! :mhartington/formatter.nvim
:cmd [ :Format :FormatWrite ]
:setup
(bind! :n :<leader>o "<cmd>Format<cr>")
(bind! :x :<leader>o ":Format<cr>")
:config
(setup! :formatter
:logging true
:log_level _G.vim.log.levels.WARN
:filetype {
:c [ (module-fn! :formatter.filetypes.c :astyle) ]
:cpp [ (module-fn! :formatter.filetypes.cpp :astyle) ]
:cmake [
(module-fn! :formatter.filetypes.cmake :cmakeformat) ]
:java [ (fn [] {:exe :astyle
:stdin true
:args [ :--mode=java ]}) ]
:sh [ (module-fn! :formatter.filetypes.sh :shfmt) ]
:rust [ (module-fn! :formatter.filetypes.rust :rustfmt) ]
:tex [ (module-fn! :formatter.filetypes.latex :latexindent) ]
:python [ (module-fn! :formatter.filetypes.python :yapf) ]
:json [ (module-fn! :formatter.filetypes.json :prettier) ]
:html [ (module-fn! :formatter.filetypes.html :prettier) ]
:css [ (module-fn! :formatter.filetypes.css :prettier) ]
:javascript [ (module-fn! :formatter.filetypes.javascript :prettier) ]
:markdown [
(module-fn! :formatter.filetypes.markdown :prettier ) ]
:fennel [ (fn [] {:exe :fnlfmt
:stdin true
:args [ "-" ]}) ]}))
;; lspconfig
(use! :neovim/nvim-lspconfig
@ -197,49 +245,18 @@
:config
(module-call! :plugin.lsp :configure))
;; null-ls.nvim
(use! :nvimtools/none-ls.nvim
(use! :j-hui/fidget.nvim
:after :nvim-lspconfig
:config
(module-call! :plugin.lsp :setup-null-ls))
(setup! :fidget))
;; nvim-jdtls
(use! :mfussenegger/nvim-jdtls
:ft :java
:after :nvim-lspconfig
:config
(module-call! :plugin.jdtls :configure))
;; formatter.nvim
;(use! :mhartington/formatter.nvim
; :cmd [ :Format :FormatWrite ]
; :setup
; (bind! :n :<leader>o "<cmd>Format<cr>")
; (bind! :v :<leader>o ":Format<cr>")
; :config
; (setup! :formatter
; :logging true
; :log_level _G.vim.log.levels.WA;RN
; :filetype {
; :c [ (module-fn! :formatter.filetypes.c :astyle) ]
; :cpp [ (module-fn! :formatter.filetypes.cpp :astyle) ]
; :cmake [
; (module-fn! :formatter.filetypes.cmake :cmakeformat) ]
; :java [ (fn [] {:exe :astyle
; :stdin true
; :args [ :--mode=java ]}) ]
; :sh [ (module-fn! :formatter.filetypes.sh :shfmt) ]
; :rust [ (module-fn! :formatter.filetypes.rust :rustfmt) ]
; :tex [ (module-fn! :formatter.filetypes.latex :latexindent) ]
; :python [ (module-fn! :formatter.filetypes.python :yapf) ]
; :json [ (module-fn! :formatter.filetypes.json :prettier) ]
; :html [ (module-fn! :formatter.filetypes.html :prettier) ]
; :css [ (module-fn! :formatter.filetypes.css :prettier) ]
; :javascript [ (module-fn! :formatter.filetypes.javascript :prettier) ]
; :markdown [
; (module-fn! :formatter.filetypes.markdown :prettier ) ]
; :fennel [ (fn [] {:exe :fnlfmt
; :stdin true
; :args [ "-" ]})]}))
;; Sync all packages on first launch
(if _G.first_launch
(module-call! :packer :sync)))

View File

@ -155,13 +155,14 @@
{ :behavior cmp.SelectBehavior.Select })
(fallback)))
[ :i :c ])}]
;(cmp.setup.cmdline "/"
; { :completion { :autocomplete true }
; :mapping cmdline-mappings
; :sources (cmp.config.sources
; [{ :name "buffer" }])})
(cmp.setup.cmdline "/"
{ :completion { :autocomplete true }
:mapping cmdline-mappings
:sources (cmp.config.sources
[{ :name "buffer" }])})
(cmp.setup.cmdline ":"
{ :completion { :autocomplete false }
:mapping cmdline-mappings
:sources (cmp.config.sources
[{ :name "cmdline" }])})))}
[{ :name "cmdline" }
{ :name "path" }])})))}

View File

@ -1,6 +1,6 @@
;;; lsp.fnl - lsp configurations
(import-macros {: bind! : setup!} :macros)
(import-macros {: bind!} :macros)
(fn on-attach [client buf]
((. (. (require :cmp) :setup) :buffer) {
@ -21,16 +21,8 @@
(bind! :n :<leader>rn vim.lsp.buf.rename buf)
(bind! :n :<leader>cn vim.lsp.buf.code_action buf)
; (bind! :n :gr vim.lsp.buf.references buf)
(bind! [ :n :v ] :<leader>o
#(vim.lsp.buf.format { :filter
;; use null-ls for formatting
(fn [client] (or
(= client.name :null-ls)
(= client.name :rust_analyzer)))
:async true }) buf)
;; Use builtin formatexpr
(vim.api.nvim_buf_set_option buf :formatexpr "")
;(when client.server_capabilities.documentFormattingProvider
; (bind! :n :<leader>o #(vim.lsp.buf.format { :async true }) buf))
;; Some telescope commands
(bind! :n :<leader>s "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
@ -44,21 +36,11 @@
(bind! :n :gd "<cmd>Telescope lsp_definitions<cr>" buf)
(bind! :n :gI "<cmd>Telescope lsp_implementations<cr>" buf)
(bind! :n :D "<cmd>Telescope lsp_type_definitions<cr>" buf)
(bind! :n :<leader>fq "<cmd>Telescope diagnostics<cr>" buf)
;; Some trouble commands
(bind! :n :<leader>q (fn []
(let [trouble (require :trouble)]
(if (trouble.is_open)
(trouble.close)
true
(trouble.open :document_diagnostics)))))
(bind! :n :<leader>Q (fn []
(let [trouble (require :trouble)]
(if (trouble.is_open)
(trouble.close)
true
(trouble.open :workspace_diagnostics))))))
(bind! :n :<leader>q "<cmd>TroubleToggle document_diagnostics<cr>")
(bind! :n :<leader>Q "<cmd>TroubleToggle workspace_diagnostics<cr>"))
(fn get-data-dir [server root]
(let [resolved_path (vim.fn.resolve root)
@ -70,7 +52,7 @@
(fn configure []
(let [lsp (require :lspconfig)
;configs (require :lspconfig.configs)
configs (require :lspconfig.configs)
lsp-cap ((. (require :cmp_nvim_lsp) :default_capabilities))
lsp-utils (require :plugin.lsp)]
(macro setup-server! [name ...]
@ -83,22 +65,8 @@
(set last-key nil))
(set last-key val)))
`((. (. lsp ,name) :setup) ,opts)))
(setup-server! :clangd
:on_attach (fn [client buf]
(lsp-utils.on-attach client buf)
(bind! :n :go :<cmd>ClangdSwitchSourceHeader<cr> buf))
:cmd [ "clangd"
"--header-insertion-decorators=0"
"--background-index"
"--clang-tidy"
"--completion-style=bundled"
"--function-arg-placeholders"
"--header-insertion=never"
"--malloc-trim"
"--pch-storage=memory"
"--offset-encoding=utf-16" ])
(setup-server! :ccls)
(setup-server! :cmake)
(setup-server! :vala_ls)
(setup-server! :gopls)
(setup-server! :rust_analyzer)
(setup-server! :texlab)
@ -115,44 +83,20 @@
:library (vim.api.nvim_get_runtime_file "" true) }
:telemetry {
:enable false }}})
(setup-server! :fennel_language_server
:settings {
:fennel {
:workspace {
:library (vim.api.nvim_list_runtime_paths) }
:diagnostics {
:globals [ "vim" ] }}})))
(tset configs :fennel_language_server {
:default_config {
:cmd [ "fennel-language-server" ]
:filetypes [ "fennel" ]
:single_file_support true
:root_dir (lsp.util.root_pattern "fnl")
:settings {
:fennel {
:workspace {
:library (vim.api.nvim_list_runtime_paths) }
:diagnostics {
:globals [ "vim" ] }}}}})
; needed to make it not complain about a nil setup function
(if configs.fennel_language_server.setup
(setup-server! :fennel_language_server))))
(fn setup-null-ls []
(let [builtins (. (require :null-ls) :builtins)]
(setup! :null-ls
:on_attach (fn [client buf]
(bind! [ :n :v ]
:<leader>o
#(vim.lsp.buf.format
{ :filter
;; use null-ls for formatting
(fn [client]
(or
(= client.name :null-ls)
(= client.name :rust_analyzer)))
:async true }) buf)
(vim.api.nvim_buf_set_option buf :formatexpr ""))
:sources [
builtins.formatting.astyle
builtins.formatting.prettier
builtins.formatting.yapf
builtins.formatting.fnlfmt
builtins.formatting.shfmt
builtins.formatting.cmake_format
builtins.formatting.stylua
(builtins.completion.spell.with { :filetypes [ :text
:markdown
:tex ]})
builtins.diagnostics.cmake_lint
;;builtins.diagnostics.codespell
;;builtins.diagnostics.shellcheck
(builtins.diagnostics.glslc.with
{ :extra_args [ "--target-env=opengl" ]})])))
{: configure : on-attach : get-data-dir : setup-null-ls }
{ : configure : on-attach : get-data-dir }

View File

@ -18,6 +18,7 @@
(bind! :n :<leader>fo "<cmd>Telescope vim_options<cr>")
(bind! :n :<leader>c "<cmd>Telescope command_history<cr>")
(bind! :n :<leader>i "<cmd>Telescope find_files<cr>")
(bind! :n :<leader>i "<cmd>Telescope find_files<cr>")
(bind! :n :z= "<cmd>Telescope spell_suggest<cr>")
(fn list-git-or-default []
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]

View File

@ -53,15 +53,13 @@
(set vim.opt.spelloptions :camel)
; Allow more freedom with the cursor
(set vim.opt.virtualedit :block)
; Enable modelines with modelineexpr off
(set vim.opt.modeline true)
(set vim.opt.modelineexpr false)
; Disable modeline for security
(set vim.opt.modeline false)
(set vim.opt.modelines 0)
; Auto chdir into files' dirs
;(set vim.opt.autochdir true)
; Enable substitute 'g' flag by default
(set vim.opt.gdefault true)
(let [ver (vim.version)]
(set vim.opt.exrc (or (> ver.major 0) (>= ver.minor 9))))
;; Remove trailing whitespace
(fn remove-trailing-whitespace []
@ -81,7 +79,7 @@
"Enabled Spellcheck"
"Disabled Spellcheck")))))
;; Enable spell in certain buffers
;; Enable spell in certian buffers
(hook! :FileType [ :text :markdown :tex :bib ]
#(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1)
(set vim.opt_local.spell true)))
@ -99,11 +97,6 @@
:extension {
"nasm" :nasm
"h" :c
"ui" :xml
"tpp" :cpp
"m" :objc }})
;; Fix filetype of terminal buffers
(hook! :BufEnter "term:/*" #(set vim.bo.filetype ""))
"ui" :xml }})
(module-call! :packer :startup (require :plugin))