Compare commits
25 Commits
7cd72735f2
...
main
Author | SHA1 | Date | |
---|---|---|---|
8e47d8bb63
|
|||
cbd4303b7f
|
|||
68f340ced5
|
|||
dbaba9e0f8
|
|||
0ef8abb561
|
|||
28a9ee34a4
|
|||
c670bf843f
|
|||
a6a553c6b0
|
|||
7ae183d64b
|
|||
77b6768742
|
|||
fc3f3415a3
|
|||
9428d38317
|
|||
1a26f6ccd6
|
|||
90fcd5db92
|
|||
3a87627581
|
|||
9e00218179
|
|||
f8ee7b4ee9
|
|||
46d1d9092d
|
|||
2880b96499
|
|||
6b53868291
|
|||
ca21ebc84d
|
|||
198ad1377f
|
|||
d37c20404d
|
|||
101360066e
|
|||
2dcd58be3e
|
@ -1,7 +1,7 @@
|
||||
;;; macros.fnl - useful macros
|
||||
|
||||
;; Helpful keymaping functions
|
||||
(lambda bind! [mode key cmd ?a1 ?a2]
|
||||
(lambda bind! [modes key cmd ?a1 ?a2]
|
||||
(let [desc (or ?a2 ?a1)
|
||||
buf (if (and ?a1 ?a2) ?a1 ?a2)
|
||||
opts { :noremap true
|
||||
@ -9,7 +9,12 @@
|
||||
:buffer buf }]
|
||||
(when desc
|
||||
(tset opts :desc desc))
|
||||
`(vim.keymap.set ,mode ,key ,cmd ,opts)))
|
||||
(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))))
|
||||
|
||||
;; Better autocommands
|
||||
(lambda hook! [hooks ?patterns callback]
|
||||
@ -21,7 +26,7 @@
|
||||
(= (type ?patterns) :table)
|
||||
?patterns
|
||||
[ ?patterns ])]
|
||||
(var group "config-hook")
|
||||
(var group (.. (tostring (math.random 0 1000000000) "-config-hook")))
|
||||
(each [_ hook (ipairs hook_table)]
|
||||
(set group (.. group "-" hook)))
|
||||
(each [_ pattern (ipairs pattern_table)]
|
||||
@ -83,7 +88,8 @@
|
||||
`(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
|
||||
|
132
fnl/plugin.fnl
132
fnl/plugin.fnl
@ -12,6 +12,12 @@
|
||||
;; 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
|
||||
@ -41,14 +47,7 @@
|
||||
:config
|
||||
(setup! :lualine
|
||||
:options { :section_separators ""
|
||||
:component_separators "│" }
|
||||
; :sections { :lualine_x [
|
||||
; { 1 #(.. "recording @" (vim.fn.reg_recording))
|
||||
; :cond #(not= (# (vim.fn.reg_recording)) 0) }
|
||||
; :encoding
|
||||
; :fileformat
|
||||
; :filetype ]}
|
||||
))
|
||||
:component_separators "│" }))
|
||||
|
||||
;; bufferline.nvim
|
||||
(use! :akinsho/bufferline.nvim
|
||||
@ -62,13 +61,15 @@
|
||||
: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-lua/plenary.nvim
|
||||
:opt true }
|
||||
{ 1 :nvim-telescope/telescope-ui-select.nvim
|
||||
:requires [ { 1 :nvim-telescope/telescope-ui-select.nvim
|
||||
:opt true }
|
||||
{ 1 :nvim-telescope/telescope-fzf-native.nvim
|
||||
:opt true
|
||||
@ -84,6 +85,7 @@
|
||||
:TroubleToggle
|
||||
:TroubleClose
|
||||
:TroubleRefresh ]
|
||||
:module :trouble
|
||||
:config
|
||||
(setup! :trouble))
|
||||
|
||||
@ -119,21 +121,6 @@
|
||||
: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" ]
|
||||
:hpp [ "cpp" "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
|
||||
@ -153,18 +140,6 @@
|
||||
: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
|
||||
@ -178,7 +153,6 @@
|
||||
: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 ]
|
||||
@ -201,42 +175,21 @@
|
||||
: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))
|
||||
|
||||
;; 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 [ "-" ]}) ]}))
|
||||
;(use! :edluffy/hologram.nvim
|
||||
; :config
|
||||
; (setup! :hologram
|
||||
; :auto_display true))
|
||||
|
||||
;; lspconfig
|
||||
(use! :neovim/nvim-lspconfig
|
||||
@ -244,18 +197,49 @@
|
||||
:config
|
||||
(module-call! :plugin.lsp :configure))
|
||||
|
||||
(use! :j-hui/fidget.nvim
|
||||
;; null-ls.nvim
|
||||
(use! :nvimtools/none-ls.nvim
|
||||
:after :nvim-lspconfig
|
||||
:config
|
||||
(setup! :fidget))
|
||||
(module-call! :plugin.lsp :setup-null-ls))
|
||||
|
||||
;; 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)))
|
||||
|
@ -155,14 +155,13 @@
|
||||
{ :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 "path" }])})))}
|
||||
[{ :name "cmdline" }])})))}
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;; lsp.fnl - lsp configurations
|
||||
|
||||
(import-macros {: bind!} :macros)
|
||||
(import-macros {: bind! : setup!} :macros)
|
||||
|
||||
(fn on-attach [client buf]
|
||||
((. (. (require :cmp) :setup) :buffer) {
|
||||
@ -21,8 +21,16 @@
|
||||
(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)
|
||||
;(when client.server_capabilities.documentFormattingProvider
|
||||
; (bind! :n :<leader>o #(vim.lsp.buf.format { :async true }) 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 "")
|
||||
|
||||
;; Some telescope commands
|
||||
(bind! :n :<leader>s "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
|
||||
@ -36,11 +44,21 @@
|
||||
(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 "<cmd>TroubleToggle document_diagnostics<cr>")
|
||||
(bind! :n :<leader>Q "<cmd>TroubleToggle workspace_diagnostics<cr>"))
|
||||
|
||||
(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))))))
|
||||
|
||||
(fn get-data-dir [server root]
|
||||
(let [resolved_path (vim.fn.resolve root)
|
||||
@ -52,7 +70,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 ...]
|
||||
@ -65,8 +83,22 @@
|
||||
(set last-key nil))
|
||||
(set last-key val)))
|
||||
`((. (. lsp ,name) :setup) ,opts)))
|
||||
(setup-server! :ccls)
|
||||
(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! :cmake)
|
||||
(setup-server! :vala_ls)
|
||||
(setup-server! :gopls)
|
||||
(setup-server! :rust_analyzer)
|
||||
(setup-server! :texlab)
|
||||
@ -83,20 +115,44 @@
|
||||
:library (vim.api.nvim_get_runtime_file "" true) }
|
||||
:telemetry {
|
||||
:enable false }}})
|
||||
(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))))
|
||||
(setup-server! :fennel_language_server
|
||||
:settings {
|
||||
:fennel {
|
||||
:workspace {
|
||||
:library (vim.api.nvim_list_runtime_paths) }
|
||||
:diagnostics {
|
||||
:globals [ "vim" ] }}})))
|
||||
|
||||
{ : configure : on-attach : get-data-dir }
|
||||
(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 }
|
||||
|
@ -18,7 +18,6 @@
|
||||
(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")]
|
||||
|
17
init.fnl
17
init.fnl
@ -53,13 +53,15 @@
|
||||
(set vim.opt.spelloptions :camel)
|
||||
; Allow more freedom with the cursor
|
||||
(set vim.opt.virtualedit :block)
|
||||
; Disable modeline for security
|
||||
(set vim.opt.modeline false)
|
||||
(set vim.opt.modelines 0)
|
||||
; Enable modelines with modelineexpr off
|
||||
(set vim.opt.modeline true)
|
||||
(set vim.opt.modelineexpr false)
|
||||
; 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 []
|
||||
@ -79,7 +81,7 @@
|
||||
"Enabled Spellcheck"
|
||||
"Disabled Spellcheck")))))
|
||||
|
||||
;; Enable spell in certian buffers
|
||||
;; Enable spell in certain buffers
|
||||
(hook! :FileType [ :text :markdown :tex :bib ]
|
||||
#(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1)
|
||||
(set vim.opt_local.spell true)))
|
||||
@ -97,6 +99,11 @@
|
||||
:extension {
|
||||
"nasm" :nasm
|
||||
"h" :c
|
||||
"ui" :xml }})
|
||||
"ui" :xml
|
||||
"tpp" :cpp
|
||||
"m" :objc }})
|
||||
|
||||
;; Fix filetype of terminal buffers
|
||||
(hook! :BufEnter "term:/*" #(set vim.bo.filetype ""))
|
||||
|
||||
(module-call! :packer :startup (require :plugin))
|
||||
|
Reference in New Issue
Block a user