Compare commits

...

55 Commits

Author SHA1 Message Date
8e47d8bb63 Update lsp.fnl 2024-02-26 14:43:32 -08:00
cbd4303b7f Fix type in plugin.fnl 2023-11-14 20:43:53 -08:00
68f340ced5 Replease null-ls with none-ls 2023-10-15 14:00:40 -07:00
dbaba9e0f8 Make .m files ObjC files 2023-09-13 03:30:31 -07:00
0ef8abb561 Added vala-language-server config 2023-09-03 02:17:04 -07:00
28a9ee34a4 Add hologram 2023-08-19 16:39:55 -07:00
c670bf843f Various updates 2023-08-19 11:31:27 -07:00
a6a553c6b0 Add back null-ls 2023-08-18 10:44:33 -07:00
7ae183d64b Remove null-ls 2023-08-16 11:22:03 -07:00
77b6768742 Various changes 2023-07-28 00:59:41 -07:00
fc3f3415a3 Fix filetype of terminal buffers 2023-05-26 14:50:58 -07:00
9428d38317 Added hy 2023-05-25 02:03:52 -07:00
1a26f6ccd6 Fix formatting 2023-05-19 15:08:56 -07:00
90fcd5db92 Fix cmp settings 2023-05-18 02:21:10 -07:00
3a87627581 Fix null-ls keybinds 2023-05-14 18:30:12 -07:00
9e00218179 Update null-fs and formatexpr settings 2023-05-14 17:41:38 -07:00
f8ee7b4ee9 Remove / search completion 2023-05-11 17:03:54 -07:00
46d1d9092d Reorganize lsp stuff 2023-05-03 23:11:28 -07:00
2880b96499 Fix typos 2023-05-03 23:04:38 -07:00
6b53868291 Enable modelines 2023-05-03 15:20:37 -07:00
ca21ebc84d Fix type 2023-05-01 22:39:30 -07:00
198ad1377f Added null-fs 2023-04-21 18:37:24 -07:00
d37c20404d Enable exrc if nvim is version 0.9.0 or higher 2023-04-14 14:42:38 -07:00
101360066e Merge branch 'main' of git.zander.im:Zander671/nvim-config 2023-03-03 21:04:55 -08:00
2dcd58be3e Add .tpp as a cpp alias 2023-03-03 21:04:21 -08:00
7cd72735f2 Try to fix bug with hidden terminal buffers 2023-02-23 11:50:06 -08:00
0c33486857 Re-organize some stuff 2023-02-23 11:41:01 -08:00
478d8a3d05 Fix goto terminal bug 2023-02-14 19:17:19 -08:00
aee57b4ae1 Change to lua_ls 2023-02-12 14:20:27 -08:00
eb3ce80e7d Changed completion's for the cmdline 2023-02-08 21:45:02 -08:00
ea6256c0ac Added arm asm syntax 2023-02-08 01:24:34 -08:00
fa057cb488 Added trouble 2023-02-07 22:31:05 -08:00
74898aacff A bunch of changes 2023-02-07 20:16:58 -08:00
1cbcabc97b Halfway done 2023-02-07 12:16:21 -08:00
9419901702 Added formatter configs 2023-02-07 11:12:09 -08:00
d6d1936973 Added formatter 2023-02-07 10:39:31 -08:00
0386262448 Added fidget plugin 2023-02-06 12:53:11 -08:00
b5dfee6620 Make substitute g flag default 2023-02-06 12:23:45 -08:00
5b6ae36a0f Added nabla 2023-02-05 15:54:06 -08:00
c1afe07afd Make japanese text not cause spell errors 2023-01-26 17:01:22 -08:00
bfff035fa1 Fix bug and remove old code 2023-01-03 00:24:32 -08:00
06142dec66 Some changes 2023-01-01 16:19:01 -08:00
271319297d A bunch of changes 2022-12-31 18:18:49 -08:00
5d67fcbb0c Added icon-picker plugin 2022-12-31 01:45:54 -08:00
8ef3d14e1e Update use! macro to work more like Emacs's use-package 2022-12-30 21:18:28 -08:00
f3d4ab7797 Added pylsp 2022-12-25 16:34:21 -08:00
380bb03ffd Remove message from whitespace removal command 2022-12-13 08:42:48 -08:00
d20db3486e Remove ts-rainbow plugin 2022-12-12 04:15:59 -08:00
9bd602b64a Remove neorg 2022-12-10 06:44:36 -08:00
2fb5f13d4a Add neorg 2022-12-10 04:59:43 -08:00
4bd0009ae6 Some random changes 2022-12-09 00:23:02 -08:00
3dfaa747ca Some random changes 2022-12-08 13:22:40 -08:00
c39aa3ddfd Add vlime 2022-12-07 03:39:47 -08:00
01fe92398a Merge branch 'main' of git.zander.im:Zander671/nvim-config 2022-12-06 19:45:02 -08:00
ee93afbd3a Change completion order and groups 2022-12-06 19:44:44 -08:00
6 changed files with 610 additions and 264 deletions

View File

@ -1,7 +1,7 @@
;;; macros.fnl - useful macros ;;; macros.fnl - useful macros
;; Helpful keymaping functions ;; Helpful keymaping functions
(lambda bind! [mode key cmd ?a1 ?a2] (lambda bind! [modes key cmd ?a1 ?a2]
(let [desc (or ?a2 ?a1) (let [desc (or ?a2 ?a1)
buf (if (and ?a1 ?a2) ?a1 ?a2) buf (if (and ?a1 ?a2) ?a1 ?a2)
opts { :noremap true opts { :noremap true
@ -9,43 +9,87 @@
:buffer buf }] :buffer buf }]
(when desc (when desc
(tset opts :desc 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 ;; Better autocommands
(lambda hook! [hooks ?patterns callback] (lambda hook! [hooks ?patterns callback]
(let [hook_table (if (= (type hooks) :table) (let [hook_table (if (= (type hooks) :table)
hooks hooks
[ hooks ]) [ hooks ])
pattern_table (if (not ?patterns) pattern_table (if (not ?patterns)
[] []
(= (type ?patterns) :table) (= (type ?patterns) :table)
?patterns ?patterns
[ ?patterns ])] [ ?patterns ])]
(var group "config-hook") (var group (.. (tostring (math.random 0 1000000000) "-config-hook")))
(each [_ hook (ipairs hook_table)] (each [_ hook (ipairs hook_table)]
(set group (.. group "-" hook))) (set group (.. group "-" hook)))
(each [_ pattern (ipairs pattern_table)] (each [_ pattern (ipairs pattern_table)]
(set group (.. group "-" pattern))) (set group (.. group "-" pattern)))
`(vim.api.nvim_create_autocmd ,hook_table `(vim.api.nvim_create_autocmd ,hook_table
{ :group { :group
(vim.api.nvim_create_augroup ,group (vim.api.nvim_create_augroup ,group
{ :clear true }) { :clear true })
:pattern ,pattern_table :pattern ,pattern_table
:callback ,callback }))) :callback ,callback })))
;; Utility functions for use!
(lambda create-list-entries [...]
(let [output { :active-entry nil
:entries {} }]
(lambda output.process [self entry]
(var result false)
(when self.active-entry
(if (and (. self :entries self.active-entry :is-first)
(not (list? entry)))
(do (tset self :entries self.active-entry :data entry)
(set self.active-entry nil)
(set result true))
(= (type entry) :string)
(set self.active-entry nil)
(do (table.insert (. self :entries self.active-entry :data) entry)
(tset self :entries self.active-entry :is-first false)
(set result true))))
(when (and (= (type entry) :string) (. self :entries entry))
(assert-compile (not (. self :entries entry :present))
(.. "':" entry "' cannot appear more than once in `use'"))
(set self.active-entry entry)
(tset self :entries entry :present true)
(set result true))
result)
(lambda output.splice-into [self other]
(each [name entry (pairs self.entries)]
(when entry.present
(tset other name entry.data))))
(each [_ val (ipairs [...])]
(tset output :entries val { :present false :is-first true :data `(lambda [])}))
output))
;; Nicer macro for use ;; Nicer macro for use
;; :config acts like use-package's :init and :config options,
;; taking in the following lisp expressions as its arguments
(lambda use! [repo ...] (lambda use! [repo ...]
(local output [ repo ]) (local output [ repo ])
(var last_key nil) (var last_key nil)
(var list_entries (create-list-entries :config :setup
:run))
(each [_ val (ipairs [...])] (each [_ val (ipairs [...])]
(if last_key (if last_key
(do (tset output last_key val) (do (tset output last_key val)
(set last_key nil)) (set last_key nil))
(not (list_entries:process val))
(set last_key val))) (set last_key val)))
(list_entries:splice-into output)
`(use ,output)) `(use ,output))
;; Can be passed to :config of `use!' ;; Call a plugin's `setup function'
;; to call a plugin's `setup' function (lambda setup! [pkg ...]
(lambda setup! [pkg ...] (local output [ ]) (local output [ ])
(var last_key nil) (var last_key nil)
(each [_ val (ipairs [...])] (each [_ val (ipairs [...])]
(if last_key (if last_key
@ -58,13 +102,25 @@
(lambda module-call! [mod func ...] (lambda module-call! [mod func ...]
`((. (require ,mod) ,func) ,...)) `((. (require ,mod) ,func) ,...))
;; Return module function ;; Return module function
(lambda module-fn! [mod func] (lambda module-fn! [mod func]
`(. (require ,mod) ,func)) `(. (require ,mod) ,func))
{: bind! ;; Basically does what the Emacs function of the same name does.
;; Wraps the code inside with a `winsaveview' and `winrestview'
(lambda save-excursion! [...]
(let [args [...]
len (# args)]
(tset args len `(let [retvar# ,(. args len)]
(vim.fn.winrestview save#)
retvar#))
`(let [save# (vim.fn.winsaveview)]
,(unpack args))))
{: bind!
: hook! : hook!
: use! : use!
: setup! : setup!
: module-call! : module-call!
: module-fn!} : module-fn!
: save-excursion!}

View File

@ -3,7 +3,7 @@
(import-macros {: bind! : hook! (import-macros {: bind! : hook!
: use! : setup! : use! : setup!
: module-call! : module-call!
: module-fn!} :macros) : module-fn! } :macros)
(fn [use] (fn [use]
;; Packer ;; Packer
@ -12,20 +12,31 @@
;; tangerine.nvim (auto fennel compile) ;; tangerine.nvim (auto fennel compile)
(use! :udayvir-singh/tangerine.nvim) (use! :udayvir-singh/tangerine.nvim)
;; hy syntax
(use! :hylang/vim-hy)
;; rainbow delimiters
(use! :HiPhish/rainbow-delimiters.nvim)
;; Treesitter ;; Treesitter
(use! :nvim-treesitter/nvim-treesitter (use! :nvim-treesitter/nvim-treesitter
:config #(setup! "nvim-treesitter.configs" :config
:ensure_installed :all (setup! :nvim-treesitter.configs
:sync_install false ;:ensure_installed :all
:auto_install true ;:sync_install false
:highlight { :enable true ;:auto_install true
:additional_vim_regex_highlighting false } :highlight { :enable true
:indent { :enable true })) :additional_vim_regex_highlighting false }
:indent { :enable true }))
;; nightfox.nvim (colorscheme) ;; nightfox.nvim (colorscheme)
(use! :EdenEast/nightfox.nvim (use! :EdenEast/nightfox.nvim
:after :nvim-treesitter :after :nvim-treesitter
:config #(vim.cmd.colorscheme :carbonfox)) :config
(vim.cmd.colorscheme :carbonfox))
;; Arm asm syntax
(use! :https://git.zander.im/Zander671/arm-syntax-vim.git)
;; Devicons ;; Devicons
(use! :kyazdani42/nvim-web-devicons) (use! :kyazdani42/nvim-web-devicons)
@ -33,135 +44,108 @@
;; lualine.nvim ;; lualine.nvim
(use! :nvim-lualine/lualine.nvim (use! :nvim-lualine/lualine.nvim
:after [ :nightfox.nvim :nvim-web-devicons ] :after [ :nightfox.nvim :nvim-web-devicons ]
:config #(setup! :lualine :config
:options { :section_separators "" (setup! :lualine
:component_separators "│" } :options { :section_separators ""
:sections { :lualine_x [ :component_separators "│" }))
{ 1 #(.. "recording @" (vim.fn.reg_recording))
:cond #(not= (# (vim.fn.reg_recording)) 0) }
:encoding
:fileformat
:filetype ]}))
;; bufferline.nvim ;; bufferline.nvim
(use! :akinsho/bufferline.nvim (use! :akinsho/bufferline.nvim
:after [ :nvim-web-devicons :nightfox.nvim ] :after [ :nvim-web-devicons :nightfox.nvim ]
:config #(setup! :bufferline :config
:options { (setup! :bufferline
:always_show_bufferline false :options {
:mode :tabs :always_show_bufferline false
:numbers :buffer-id :mode :tabs
:show_buffer_close_icons false :numbers :buffer-id
:show_close_icon false })) :show_buffer_close_icons false
:show_close_icon false }))
;; fzf (a fuzzy finder) (use! :nvim-lua/plenary.nvim
(use! :ibhagwan/fzf-lua :opt true
:config #(let [fzf (require :fzf-lua)] :module :plenary)
(fzf.register_ui_select)
(bind! :n :<leader>fq fzf.quickfix) ;; telescope (a fuzzy finder)
(bind! :n :<leader>fr fzf.registers) (use! :nvim-telescope/telescope.nvim
(bind! :n :<leader>fj fzf.jumps) :cmd :Telescope
(bind! :n :<leader>fa fzf.marks) :module :telescope
(bind! :n :<leader>fh fzf.help_tags) :requires [ { 1 :nvim-telescope/telescope-ui-select.nvim
(bind! :n :<leader>g fzf.live_grep) :opt true }
(bind! :n :<leader>fg fzf.live_grep) { 1 :nvim-telescope/telescope-fzf-native.nvim
(bind! :n :<leader>G fzf.grep) :opt true
(bind! :n :<leader>fG fzf.grep) :run :make }]
(bind! :n :<leader>b fzf.buffers) :setup
(bind! :n :gb fzf.buffers) (module-call! :plugin.telescope :setup)
(bind! :n :<leader>fu fzf.git_status) :config
(bind! :n :<leader>fm fzf.man_pages) (module-call! :plugin.telescope :config))
(bind! :n :<leader>fe fzf.diagnostics_document)
(bind! :n :<leader>fE fzf.diagnostics_workspace) ;; Trouble
(bind! :n :<leader>fp fzf.spell_suggest) (use! :folke/trouble.nvim
(bind! :n :<leader>i fzf.files) :cmd [ :Trouble
(bind! :n :z= fzf.spell_suggest) :TroubleToggle
(bind! :n :<leader>ff (fn [] :TroubleClose
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")] :TroubleRefresh ]
(if (= code 0) :module :trouble
(fzf.git_files) :config
(fzf.files))))) (setup! :trouble))
(fn jump-or-open-terminal []
"If no terminal buffer exists, create one. Otherwise, open new one."
(var term_count 0)
(var last_id 0)
(var terms [ ])
(each [_ id (pairs (vim.api.nvim_list_bufs))]
(let [name (vim.api.nvim_buf_get_name id)]
(when (vim.startswith name "term://")
(table.insert terms name)
(set term_count (+ term_count 1))
(set last_id id))))
(if (= term_count 0)
(vim.cmd.terminal)
(= term_count 1)
(vim.cmd.buffer last_id)
(fzf.buffers { :query "term://" })))
(bind! :n :<leader>t jump-or-open-terminal)))
;; Nvim surround ;; Nvim surround
(use! :kylechui/nvim-surround (use! :kylechui/nvim-surround
:config #(setup! :nvim-surround)) :config
(setup! :nvim-surround))
;; Leap ;; Leap
(use! :ggandor/leap.nvim (use! :ggandor/leap.nvim
:after :nvim-treesitter :after :nvim-treesitter
:config (fn [] :config
((. (require :leap) :add_default_mappings)) ((. (require :leap) :add_default_mappings))
(bind! :o :z "<plug>(leap-forward-to)") (bind! :o :z "<plug>(leap-forward-to)")
(bind! :o :Z "<plug>(leap-backward-to)") (bind! :o :Z "<plug>(leap-backward-to)")
(vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment }))) (vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment }))
;; Leap spooky (remote operations) ;; Leap spooky (remote operations)
(use! :ggandor/leap-spooky.nvim (use! :ggandor/leap-spooky.nvim
:after :leap.nvim :after :leap.nvim
:config #(setup! :leap-spooky)) :config
(setup! :leap-spooky))
;; Flit (leap for 'till' and 'forward' motions) ;; Flit (leap for 'till' and 'forward' motions)
(use! :ggandor/flit.nvim (use! :ggandor/flit.nvim
:after :leap.nvim :after :leap.nvim
:config #(setup! :flit)) :config
(setup! :flit))
;; Comment.nvim ;; Comment.nvim
(use! :numToStr/Comment.nvim (use! :numToStr/Comment.nvim
:config #(setup! :Comment)) :keys [ :gc :gb ]
:config
;; nvim-find-other (setup! :Comment))
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
:config (fn [] (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 (use! :RRethy/vim-illuminate
:config (fn [] :config
(module-call! :illuminate :configure) (module-call! :illuminate
{ :providers [ :configure { :providers [
"lsp" "lsp"
"treesitter" "treesitter"
"ragex" ] "ragex" ]
:modes_denylist [ :filetypes_denylist [
:markdown :Trouble
:text :markdown
:gitconfig :text
:gitignore ] :gitconfig
:delay 0 } :gitignore ]
(hook! :FileType :lua #(vim.api.nvim_set_hl 0 :delay 0 })
:IlluminatedWordText (hook! :FileType :lua #(vim.api.nvim_set_hl 0
{})))) :IlluminatedWordText
{})))
;; Snippy ;; Snippy
(use! :dcampos/nvim-snippy (use! :dcampos/nvim-snippy
:config #(let [map (require :snippy.mapping)] :config
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>)) (let [map (require :snippy.mapping)]
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>)))) (bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
;; nvim-cmp (autocomplete) ;; nvim-cmp (autocomplete)
(use! :hrsh7th/nvim-cmp (use! :hrsh7th/nvim-cmp
@ -172,18 +156,89 @@
{ 1 :ray-x/cmp-treesitter { 1 :ray-x/cmp-treesitter
:after :nvim-cmp } :after :nvim-cmp }
:dcampos/cmp-snippy ] :dcampos/cmp-snippy ]
:config (module-fn! :plugin.cmp :configure)) :config
(module-call! :plugin.cmp :configure))
;; does what the name says, lets you pick icons
(use! :ziontee113/icon-picker.nvim
:cmd [ :IconPickerNormal :IconPickerYank ]
:setup
(bind! :n :<leader>ci "<cmd>IconPickerNormal<cr>")
(bind! :n :<leader>cy "<cmd>IconPickerYank<cr>")
:config
(vim.cmd "PackerLoad telescope.nvim")
(setup! :icon-picker
:disable_legacy_commands true))
(use! :jbyuki/nabla.nvim
:module :nabla
: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))
;; lspconfig ;; lspconfig
(use! :neovim/nvim-lspconfig (use! :neovim/nvim-lspconfig
:after [ :cmp-nvim-lsp :after :cmp-nvim-lsp
:fzf-lua ] :config
:config (module-fn! :plugin.lsp :configure)) (module-call! :plugin.lsp :configure))
;; null-ls.nvim
(use! :nvimtools/none-ls.nvim
:after :nvim-lspconfig
:config
(module-call! :plugin.lsp :setup-null-ls))
;; nvim-jdtls ;; nvim-jdtls
(use! :mfussenegger/nvim-jdtls (use! :mfussenegger/nvim-jdtls
:after :nvim-lspconfig :config
:config (module-fn! :plugin.jdtls :configure)) (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 ;; Sync all packages on first launch
(if _G.first_launch (if _G.first_launch

View File

@ -4,85 +4,164 @@
{ :configure #(let [cmp (require :cmp) { :configure #(let [cmp (require :cmp)
compare (require :cmp.config.compare)] compare (require :cmp.config.compare)]
(cmp.setup (cmp.setup
{ :snippet { { :snippet {
:expand #(module-call! :snippy :expand_snippet $1.body) } :expand #(module-call! :snippy :expand_snippet $1.body) }
:mapping { :mapping {
:<C-b> (cmp.mapping (cmp.mapping.scroll_docs -4) :<C-b> (cmp.mapping (cmp.mapping.scroll_docs -4)
[ :i :c ]) [ :i :c ])
:<C-f> (cmp.mapping (cmp.mapping.scroll_docs 4) :<C-f> (cmp.mapping (cmp.mapping.scroll_docs 4)
[ :i :c ]) [ :i :c ])
:<C-space> (cmp.mapping (cmp.mapping.complete) :<C-space> (cmp.mapping (cmp.mapping.complete)
[ :i :c ])
:<C-e> (cmp.mapping (cmp.mapping.abort)
[ :i :c ])
:<cr> (cmp.mapping
(cmp.mapping.confirm { :select false })
[ :i :c ])
:<C-j> (cmp.mapping
(cmp.mapping.select_next_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-k> (cmp.mapping
(cmp.mapping.select_prev_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-n> (cmp.mapping
(cmp.mapping.select_next_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-p> (cmp.mapping
(cmp.mapping.select_prev_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<down> (cmp.mapping
(cmp.mapping.select_next_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<up> (cmp.mapping
(cmp.mapping.select_prev_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ]) }
:formatting {
:format (fn [entry vim_item]
(tset vim_item :menu
(. { :nvim_lsp "[LSP]"
:treesitter "[TS]"
:snippy "[Snippy]"
:buffer "[Buffer]"
:path "[Path]"
:vlime "[Vlime]" }
entry.source.name))
vim_item)
}
:sources [{ :name "snippy" :priority 2 :group 1 }
{ :name "treesitter" :priority 1 :group 2 }
{ :name "buffer" :priority 0 :group 3 }
{ :name "path" :priority 0 :group 4 }]
:view {
:entries {
:name "custom"
; :selection_order "near_cursor"
}}
:sorting {
:priority_weight 2
:comparators [
compare.score
compare.locality
compare.recently_used
compare.offset
compare.order
; compare.scopes
; compare.exact
; compare.sort_text
; compare.kind
; compare.length
]}})
(cmp.setup.filetype [ :lisp ]
{ :option { :fuzzy false }
:sources
[{ :name "vlime" :priority 2 :group 1 }
{ :name "snippy" :priority 2 :group 2 }
{ :name "buffer" :priority 0 :group 3 }
{ :name "path" :priority 0 :group 4 }]})
(let [cmdline-mappings
{ :<C-space> (cmp.mapping (cmp.mapping.complete)
[ :i :c ])
:<C-e> (cmp.mapping (cmp.mapping.abort)
[ :i :c ]) [ :i :c ])
:<C-e> (cmp.mapping (cmp.mapping.abort) :<cr> (cmp.mapping
[ :i :c ]) (cmp.mapping.confirm { :select false })
:<CR> (cmp.mapping [ :i :c ])
(cmp.mapping.confirm { :select false }) :<Tab> (cmp.mapping
[ :i :c ]) (fn []
:<C-j> (cmp.mapping (if (cmp.visible)
(cmp.mapping.select_next_item (cmp.select_prev_item)
{ :behavior cmp.SelectBehavior.Select }) (do
[ :i :c ]) (cmp.complete)
:<C-k> (cmp.mapping (cmp.complete_common_string))))
(cmp.mapping.select_prev_item [ :i :c ])
{ :behavior cmp.SelectBehavior.Select }) :<S-Tab> (cmp.mapping
[ :i :c ]) (fn []
:<C-n> (cmp.mapping (if (cmp.visible)
(cmp.mapping.select_next_item (cmp.select_next_item)
{ :behavior cmp.SelectBehavior.Select }) (do
[ :i :c ]) (cmp.complete)
:<C-p> (cmp.mapping (cmp.complete_common_string))))
(cmp.mapping.select_prev_item [ :i :c ])
{ :behavior cmp.SelectBehavior.Select }) :<C-k> (cmp.mapping
[ :i :c ]) (fn []
:<down> (cmp.mapping (if (cmp.visible)
(cmp.mapping.select_next_item (cmp.select_prev_item
{ :behavior cmp.SelectBehavior.Select }) { :behavior cmp.SelectBehavior.Select })
[ :i :c ]) (vim.api.nvim_feedkeys
:<up> (cmp.mapping (vim.api.nvim_replace_termcodes :<up>
(cmp.mapping.select_prev_item true
{ :behavior cmp.SelectBehavior.Select }) false
[ :i :c ]) } true)
:formatting { :n false)))
:format (fn [entry vim_item] [ :i :c ])
(tset vim_item :menu :<C-j> (cmp.mapping
(. { :nvim_lsp "[LSP]" (fn []
:treesitter "[TS]" (if (cmp.visible)
:snippy "[Snippy]" (cmp.select_next_item
:buffer "[Buffer]" { :behavior cmp.SelectBehavior.Select })
:path "[Path]" } (vim.api.nvim_feedkeys
entry.source.name)) (vim.api.nvim_replace_termcodes :<down>
vim_item) true
} false
:sources (cmp.config.sources true)
[{ :name "nvim_lsp" :priority 2 } :n false)))
{ :name "snippy" :priority 1 } [ :i :c ])
{ :name "buffer" :priority 0 } :<C-p> (cmp.mapping
{ :name "path" :priority 0 }] (cmp.mapping.select_prev_item
[{ :name "treesitter" :priority 2 } { :behavior cmp.SelectBehavior.Select })
{ :name "snippy" :priority 1 } [ :i :c ])
{ :name "buffer" :priority 0 } :<C-n> (cmp.mapping
{ :name "path" :priority 0 }]) (cmp.mapping.select_next_item
:sorting { { :behavior cmp.SelectBehavior.Select })
:priority_weight 2 [ :i :c ])
:comparators [ :<up> (cmp.mapping
compare.score (fn [fallback]
compare.locality (if (cmp.visible)
compare.recently_used (cmp.select_prev_item
compare.offset { :behavior cmp.SelectBehavior.Select })
compare.order (fallback)))
; compare.scopes [ :i :c ])
; compare.exact :<down> (cmp.mapping
; compare.sort_text (fn [fallback]
; compare.kind (if (cmp.visible)
; compare.length (cmp.select_next_item
]}}) { :behavior cmp.SelectBehavior.Select })
(cmp.setup.cmdline "/" (fallback)))
{ :mapping (cmp.mapping.preset.cmdline) [ :i :c ])}]
:sources (cmp.config.sources ;(cmp.setup.cmdline "/"
[{ :name "buffer" }])}) ; { :completion { :autocomplete true }
; :mapping cmdline-mappings
; :sources (cmp.config.sources
; [{ :name "buffer" }])})
(cmp.setup.cmdline ":" (cmp.setup.cmdline ":"
{ :mapping (cmp.mapping.preset.cmdline) { :completion { :autocomplete false }
:sources (cmp.config.sources :mapping cmdline-mappings
[{ :name "cmdline" } :sources (cmp.config.sources
{ :name "path" }])}))} [{ :name "cmdline" }])})))}

View File

@ -1,32 +1,64 @@
;;; lsp.fnl - lsp configurations ;;; lsp.fnl - lsp configurations
(import-macros {: bind!} :macros) (import-macros {: bind! : setup!} :macros)
(fn on-attach [_ buf] (fn on-attach [client buf]
((. (. (require :cmp) :setup) :buffer) {
:sources [{ :name "nvim_lsp" :priority 1 :group 1 }
{ :name "snippy" :priority 1 :group 2 }
{ :name "buffer" :priority 0 :group 3 }
{ :name "path" :priority 0 :group 4 }]})
(bind! :n :gD vim.lsp.buf.declaration buf) (bind! :n :gD vim.lsp.buf.declaration buf)
(bind! :n :gd vim.lsp.buf.definition buf) ; (bind! :n :gd vim.lsp.buf.definition buf)
(bind! :n :K vim.lsp.buf.hover buf) (bind! :n :K vim.lsp.buf.hover buf)
(bind! :n :gI vim.lsp.buf.implementation buf) ; (bind! :n :gI vim.lsp.buf.implementation buf)
(bind! :n :<C-k> vim.lsp.buf.signature_help buf) (bind! :n :<C-k> vim.lsp.buf.signature_help buf)
(bind! :n :<leader>wa vim.lsp.buf.add_workspace_folder buf) (bind! :n :<leader>wa vim.lsp.buf.add_workspace_folder buf)
(bind! :n :<leader>wr vim.lsp.buf.remove_workspace_folder buf) (bind! :n :<leader>wr vim.lsp.buf.remove_workspace_folder buf)
(bind! :n :<leader>wl #(print (vim.inspect (bind! :n :<leader>wl #(print (vim.inspect
(vim.lsp.buf.list_workspace_folders))) buf) (vim.lsp.buf.list_workspace_folders))) buf)
(bind! :n :<leader>D vim.lsp.buf.type_definition buf) ; (bind! :n :<leader>D vim.lsp.buf.type_definition buf)
(bind! :n :<leader>rn vim.lsp.buf.rename buf) (bind! :n :<leader>rn vim.lsp.buf.rename buf)
; (bind! :n :<leader>cn vim.lsp.buf.code_action buf) (bind! :n :<leader>cn vim.lsp.buf.code_action buf)
; (bind! :n :gr vim.lsp.buf.references buf) ; (bind! :n :gr vim.lsp.buf.references buf)
(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 ;; Some telescope commands
(let [fzf (require :fzf-lua)] (bind! :n :<leader>s "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
(bind! :n :gr fzf.lsp_references buf) (bind! :n :<leader>fs "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
(bind! :n :<leader>s fzf.lsp_live_workspace_symbols buf) (bind! :n :<leader>fS "<cmd>Telescope lsp_workspace_symbols<cr>" buf)
(bind! :n :<leader>fs fzf.lsp_live_workspace_symbols buf) ;(print (vim.inspect client.server_capabilities))
(bind! :n :<leader>fS fzf.lsp_workspace_symbols buf) (when client.server_capabilities.documentSymbolProvider
(bind! :n :<leader>d fzf.lsp_document_symbols buf) (bind! :n :<leader>d "<cmd>Telescope lsp_document_symbols<cr>" buf)
(bind! :n :<leader>fd fzf.lsp_document_symbols buf) (bind! :n :<leader>fd "<cmd>Telescope lsp_document_symbols<cr>" buf))
(bind! :n :<leader>cn fzf.lsp_code_actions buf))) (bind! :n :gr "<cmd>Telescope lsp_references<cr>" buf)
(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))))))
(fn get-data-dir [server root] (fn get-data-dir [server root]
(let [resolved_path (vim.fn.resolve root) (let [resolved_path (vim.fn.resolve root)
@ -38,7 +70,7 @@
(fn configure [] (fn configure []
(let [lsp (require :lspconfig) (let [lsp (require :lspconfig)
configs (require :lspconfig.configs) ;configs (require :lspconfig.configs)
lsp-cap ((. (require :cmp_nvim_lsp) :default_capabilities)) lsp-cap ((. (require :cmp_nvim_lsp) :default_capabilities))
lsp-utils (require :plugin.lsp)] lsp-utils (require :plugin.lsp)]
(macro setup-server! [name ...] (macro setup-server! [name ...]
@ -51,12 +83,27 @@
(set last-key nil)) (set last-key nil))
(set last-key val))) (set last-key val)))
`((. (. lsp ,name) :setup) ,opts))) `((. (. 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! :cmake)
(setup-server! :vala_ls)
(setup-server! :gopls) (setup-server! :gopls)
(setup-server! :rust_analyzer) (setup-server! :rust_analyzer)
(setup-server! :texlab) (setup-server! :texlab)
(setup-server! :sumneko_lua (setup-server! :pylsp)
(setup-server! :lua_ls
:settings { :settings {
:Lua { :Lua {
:runtime { :runtime {
@ -68,20 +115,44 @@
:library (vim.api.nvim_get_runtime_file "" true) } :library (vim.api.nvim_get_runtime_file "" true) }
:telemetry { :telemetry {
:enable false }}}) :enable false }}})
(tset configs :fennel_language_server { (setup-server! :fennel_language_server
:default_config { :settings {
:cmd [ "fennel-language-server" ] :fennel {
:filetypes [ "fennel" ] :workspace {
:single_file_support true :library (vim.api.nvim_list_runtime_paths) }
:root_dir (lsp.util.root_pattern "fnl") :diagnostics {
:settings { :globals [ "vim" ] }}})))
: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))))
{ : 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 }

71
fnl/plugin/telescope.fnl Normal file
View File

@ -0,0 +1,71 @@
(import-macros {: bind! : setup! : module-call!} :macros)
{ :setup (fn []
(bind! :n :<leader>fq "<cmd>Telescope quickfix<cr>")
(bind! :n :<leader>fr "<cmd>Telescope registers<cr>")
(bind! :n :<leader>fj "<cmd>Telescope jumplist<cr>")
(bind! :n :<leader>fa "<cmd>Telescope marks<cr>")
(bind! :n :<leader>fh "<cmd>Telescope help_tags<cr>")
(bind! :n :<leader>g "<cmd>Telescope live_grep<cr>")
(bind! :n :<leader>fg "<cmd>Telescope live_grep<cr>")
(bind! :n :<leader>d "<cmd>Telescope treesitter<cr>")
(bind! :n :<leader>b "<cmd>Telescope buffers<cr>")
(bind! :n :<leader>fu "<cmd>Telescope git_status<cr>")
(bind! :n :<leader>fm "<cmd>Telescope man_pages<cr>")
(bind! :n :<leader>fe "<cmd>Telescope diagnostics<cr>")
(bind! :n :<leader>fl "<cmd>Telescope loclist<cr>")
(bind! :n :<leader>fp "<cmd>Telescope spell_suggest<cr>")
(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 :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")]
(if (= code 0)
(vim.cmd "Telescope git_files")
(vim.cmd "Telescope find_files"))))
(bind! :n :<leader>ff list-git-or-default)
(bind! :n :<leader>u list-git-or-default)
(fn jump-or-open-terminal []
"If no terminal buffer exists, create one. Otherwise, open new one."
(var term_count 0)
(var last_id 0)
(var terms [ ])
(each [_ id (pairs (vim.api.nvim_list_bufs))]
(when (and (vim.api.nvim_buf_is_loaded id)
(vim.api.nvim_buf_get_option id :buflisted))
(let [name (vim.api.nvim_buf_get_name id)]
(when (vim.startswith name "term://")
(table.insert terms name)
(set term_count (+ term_count 1))
(set last_id id)))))
(if (= term_count 0)
(vim.cmd.terminal)
(= term_count 1)
(vim.cmd.buffer last_id)
(vim.cmd "Telescope buffers default_text=term://")))
(bind! :n :<leader>t jump-or-open-terminal))
:config (fn []
(vim.cmd "PackerLoad plenary.nvim")
(vim.cmd "PackerLoad telescope-ui-select.nvim")
(vim.cmd "PackerLoad telescope-fzf-native.nvim")
(let [actions (require :telescope.actions)]
(setup! :telescope
:defaults {
:mappings {
:i { :<esc> actions.close
:<C-k> actions.move_selection_previous
:<C-j> actions.move_selection_next }
:n { :<C-k> actions.move_selection_previous
:<C-j> actions.move_selection_next }}}
:pickers {
:buffers {
;;:ignore_current_buffer true
:sort_lastused true }}
:extensions {
:ui-select [
(module-call! :telescope.themes :get_dropdown)
]
})
(module-call! :telescope :load_extension :ui-select)
(module-call! :telescope :load_extension :fzf))) }

View File

@ -1,6 +1,7 @@
;;; init.fnl - primary init file ;;; init.fnl - primary init file
(import-macros {: bind! : module-call! : hook!} :macros) (import-macros {: bind! : module-call! : hook!
: save-excursion! } :macros)
;; Make space leader ;; Make space leader
(set vim.g.mapleader " ") (set vim.g.mapleader " ")
@ -47,32 +48,40 @@
(set vim.opt.undofile true) (set vim.opt.undofile true)
; Text width ; Text width
(set vim.opt.textwidth 80) (set vim.opt.textwidth 80)
; Spell options ; Spell optionis
(set vim.opt.spelllang :en_us) (set vim.opt.spelllang "en_us,cjk")
(set vim.opt.spelloptions :camel) (set vim.opt.spelloptions :camel)
; Allow more freedom with the cursor ; Allow more freedom with the cursor
(set vim.opt.virtualedit :block) (set vim.opt.virtualedit :block)
; 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 ;; Remove trailing whitespace
(fn remove-trailing-whitespace [] (fn remove-trailing-whitespace []
"Remove trailing whitespace from the whole file." "Remove trailing whitespace from the whole file."
(let [res (pcall vim.cmd "%s/ \\+$//gc")] (save-excursion!
(vim.cmd.nohlsearch) (vim.api.nvim_exec "keepjumps keeppatterns silent! %s/ \\+$//" false)
(when (not res) (vim.api.nvim_exec "keepjumps keeppatterns silent! 0;/^\\%(\\n*.\\)\\@!/,$d_" false)))
(print "File is clean"))))
(vim.api.nvim_create_user_command :RemoveTrailingWhitespace (vim.api.nvim_create_user_command :RemoveTrailingWhitespace
remove-trailing-whitespace {}) remove-trailing-whitespace {})
(bind! :n :<leader>ws remove-trailing-whitespace) (hook! [ :BufWritePre ] "*" remove-trailing-whitespace)
;; Spell keybindings ;; Spell keybindings
(bind! :n :<leader>l (fn [] (bind! :n :<leader>l (fn []
(let [new-spell (not (vim.opt_local.spell:get))] (let [new-spell (not (vim.opt_local.spell:get))]
(set vim.opt_local.spell new-spell) (set vim.opt_local.spell new-spell)
(print (if new-spell (print (if new-spell
"Enabled Spellcheck" "Enabled Spellcheck"
"Disabled Spellcheck"))))) "Disabled Spellcheck")))))
;; Enable spell in certian buffers ;; Enable spell in certain buffers
(hook! :FileType [ :text :markdown :tex :bib ] (hook! :FileType [ :text :markdown :tex :bib ]
#(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1) #(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1)
(set vim.opt_local.spell true))) (set vim.opt_local.spell true)))
@ -90,6 +99,11 @@
:extension { :extension {
"nasm" :nasm "nasm" :nasm
"h" :c "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)) (module-call! :packer :startup (require :plugin))