Compare commits
55 Commits
eaee2be5ef
...
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
|
|||
7cd72735f2
|
|||
0c33486857
|
|||
478d8a3d05
|
|||
aee57b4ae1
|
|||
eb3ce80e7d
|
|||
ea6256c0ac
|
|||
fa057cb488
|
|||
74898aacff
|
|||
1cbcabc97b
|
|||
9419901702
|
|||
d6d1936973
|
|||
0386262448
|
|||
b5dfee6620
|
|||
5b6ae36a0f
|
|||
c1afe07afd
|
|||
bfff035fa1
|
|||
06142dec66
|
|||
271319297d
|
|||
5d67fcbb0c
|
|||
8ef3d14e1e
|
|||
f3d4ab7797
|
|||
380bb03ffd
|
|||
d20db3486e
|
|||
9bd602b64a
|
|||
2fb5f13d4a
|
|||
4bd0009ae6
|
|||
3dfaa747ca
|
|||
c39aa3ddfd
|
|||
01fe92398a
|
|||
ee93afbd3a
|
@ -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,43 +9,87 @@
|
||||
: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]
|
||||
(let [hook_table (if (= (type hooks) :table)
|
||||
hooks
|
||||
(let [hook_table (if (= (type hooks) :table)
|
||||
hooks
|
||||
[ hooks ])
|
||||
pattern_table (if (not ?patterns)
|
||||
[]
|
||||
(= (type ?patterns) :table)
|
||||
?patterns
|
||||
?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)]
|
||||
(set group (.. group "-" pattern)))
|
||||
`(vim.api.nvim_create_autocmd ,hook_table
|
||||
{ :group
|
||||
(vim.api.nvim_create_augroup ,group
|
||||
{ :group
|
||||
(vim.api.nvim_create_augroup ,group
|
||||
{ :clear true })
|
||||
:pattern ,pattern_table
|
||||
:pattern ,pattern_table
|
||||
: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
|
||||
;; :config acts like use-package's :init and :config options,
|
||||
;; taking in the following lisp expressions as its arguments
|
||||
(lambda use! [repo ...]
|
||||
(local output [ repo ])
|
||||
(var last_key nil)
|
||||
(var list_entries (create-list-entries :config :setup
|
||||
:run))
|
||||
(each [_ val (ipairs [...])]
|
||||
(if last_key
|
||||
(do (tset output last_key val)
|
||||
(set last_key nil))
|
||||
(do (tset output last_key val)
|
||||
(set last_key nil))
|
||||
(not (list_entries:process val))
|
||||
(set last_key val)))
|
||||
(list_entries:splice-into output)
|
||||
`(use ,output))
|
||||
|
||||
;; Can be passed to :config of `use!'
|
||||
;; to call a plugin's `setup' function
|
||||
(lambda setup! [pkg ...] (local output [ ])
|
||||
;; Call a plugin's `setup function'
|
||||
(lambda setup! [pkg ...]
|
||||
(local output [ ])
|
||||
(var last_key nil)
|
||||
(each [_ val (ipairs [...])]
|
||||
(if last_key
|
||||
@ -58,13 +102,25 @@
|
||||
(lambda module-call! [mod func ...]
|
||||
`((. (require ,mod) ,func) ,...))
|
||||
|
||||
;; Return module function
|
||||
;; Return module function
|
||||
(lambda module-fn! [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!
|
||||
: use!
|
||||
: setup!
|
||||
: module-call!
|
||||
: module-fn!}
|
||||
: module-fn!
|
||||
: save-excursion!}
|
||||
|
287
fnl/plugin.fnl
287
fnl/plugin.fnl
@ -3,7 +3,7 @@
|
||||
(import-macros {: bind! : hook!
|
||||
: use! : setup!
|
||||
: module-call!
|
||||
: module-fn!} :macros)
|
||||
: module-fn! } :macros)
|
||||
|
||||
(fn [use]
|
||||
;; Packer
|
||||
@ -12,20 +12,31 @@
|
||||
;; 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 #(setup! "nvim-treesitter.configs"
|
||||
:ensure_installed :all
|
||||
:sync_install false
|
||||
:auto_install true
|
||||
:highlight { :enable true
|
||||
:additional_vim_regex_highlighting false }
|
||||
:indent { :enable true }))
|
||||
:config
|
||||
(setup! :nvim-treesitter.configs
|
||||
;:ensure_installed :all
|
||||
;:sync_install false
|
||||
;:auto_install true
|
||||
:highlight { :enable true
|
||||
:additional_vim_regex_highlighting false }
|
||||
:indent { :enable true }))
|
||||
|
||||
;; nightfox.nvim (colorscheme)
|
||||
(use! :EdenEast/nightfox.nvim
|
||||
: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
|
||||
(use! :kyazdani42/nvim-web-devicons)
|
||||
@ -33,135 +44,108 @@
|
||||
;; lualine.nvim
|
||||
(use! :nvim-lualine/lualine.nvim
|
||||
:after [ :nightfox.nvim :nvim-web-devicons ]
|
||||
: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 ]}))
|
||||
:config
|
||||
(setup! :lualine
|
||||
:options { :section_separators ""
|
||||
:component_separators "│" }))
|
||||
|
||||
;; bufferline.nvim
|
||||
(use! :akinsho/bufferline.nvim
|
||||
:after [ :nvim-web-devicons :nightfox.nvim ]
|
||||
:config #(setup! :bufferline
|
||||
:options {
|
||||
:always_show_bufferline false
|
||||
:mode :tabs
|
||||
:numbers :buffer-id
|
||||
:show_buffer_close_icons false
|
||||
:show_close_icon false }))
|
||||
:config
|
||||
(setup! :bufferline
|
||||
:options {
|
||||
:always_show_bufferline false
|
||||
:mode :tabs
|
||||
:numbers :buffer-id
|
||||
:show_buffer_close_icons false
|
||||
:show_close_icon false }))
|
||||
|
||||
;; fzf (a fuzzy finder)
|
||||
(use! :ibhagwan/fzf-lua
|
||||
:config #(let [fzf (require :fzf-lua)]
|
||||
(fzf.register_ui_select)
|
||||
(bind! :n :<leader>fq fzf.quickfix)
|
||||
(bind! :n :<leader>fr fzf.registers)
|
||||
(bind! :n :<leader>fj fzf.jumps)
|
||||
(bind! :n :<leader>fa fzf.marks)
|
||||
(bind! :n :<leader>fh fzf.help_tags)
|
||||
(bind! :n :<leader>g fzf.live_grep)
|
||||
(bind! :n :<leader>fg fzf.live_grep)
|
||||
(bind! :n :<leader>G fzf.grep)
|
||||
(bind! :n :<leader>fG fzf.grep)
|
||||
(bind! :n :<leader>b fzf.buffers)
|
||||
(bind! :n :gb fzf.buffers)
|
||||
(bind! :n :<leader>fu fzf.git_status)
|
||||
(bind! :n :<leader>fm fzf.man_pages)
|
||||
(bind! :n :<leader>fe fzf.diagnostics_document)
|
||||
(bind! :n :<leader>fE fzf.diagnostics_workspace)
|
||||
(bind! :n :<leader>fp fzf.spell_suggest)
|
||||
(bind! :n :<leader>i fzf.files)
|
||||
(bind! :n :z= fzf.spell_suggest)
|
||||
(bind! :n :<leader>ff (fn []
|
||||
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
|
||||
(if (= code 0)
|
||||
(fzf.git_files)
|
||||
(fzf.files)))))
|
||||
(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)))
|
||||
(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
|
||||
:opt true }
|
||||
{ 1 :nvim-telescope/telescope-fzf-native.nvim
|
||||
:opt true
|
||||
:run :make }]
|
||||
:setup
|
||||
(module-call! :plugin.telescope :setup)
|
||||
:config
|
||||
(module-call! :plugin.telescope :config))
|
||||
|
||||
;; Trouble
|
||||
(use! :folke/trouble.nvim
|
||||
:cmd [ :Trouble
|
||||
:TroubleToggle
|
||||
:TroubleClose
|
||||
:TroubleRefresh ]
|
||||
:module :trouble
|
||||
:config
|
||||
(setup! :trouble))
|
||||
|
||||
;; Nvim surround
|
||||
(use! :kylechui/nvim-surround
|
||||
:config #(setup! :nvim-surround))
|
||||
:config
|
||||
(setup! :nvim-surround))
|
||||
|
||||
;; Leap
|
||||
(use! :ggandor/leap.nvim
|
||||
:after :nvim-treesitter
|
||||
:config (fn []
|
||||
((. (require :leap) :add_default_mappings))
|
||||
(bind! :o :z "<plug>(leap-forward-to)")
|
||||
(bind! :o :Z "<plug>(leap-backward-to)")
|
||||
(vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment })))
|
||||
:config
|
||||
((. (require :leap) :add_default_mappings))
|
||||
(bind! :o :z "<plug>(leap-forward-to)")
|
||||
(bind! :o :Z "<plug>(leap-backward-to)")
|
||||
(vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment }))
|
||||
|
||||
;; Leap spooky (remote operations)
|
||||
(use! :ggandor/leap-spooky.nvim
|
||||
:after :leap.nvim
|
||||
:config #(setup! :leap-spooky))
|
||||
:config
|
||||
(setup! :leap-spooky))
|
||||
|
||||
;; Flit (leap for 'till' and 'forward' motions)
|
||||
(use! :ggandor/flit.nvim
|
||||
:after :leap.nvim
|
||||
:config #(setup! :flit))
|
||||
:config
|
||||
(setup! :flit))
|
||||
|
||||
;; Comment.nvim
|
||||
(use! :numToStr/Comment.nvim
|
||||
:config #(setup! :Comment))
|
||||
|
||||
;; nvim-find-other
|
||||
(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))))
|
||||
:keys [ :gc :gb ]
|
||||
:config
|
||||
(setup! :Comment))
|
||||
|
||||
;; illuminate (same symbol highlight)
|
||||
(use! :RRethy/vim-illuminate
|
||||
:config (fn []
|
||||
(module-call! :illuminate :configure)
|
||||
{ :providers [
|
||||
"lsp"
|
||||
"treesitter"
|
||||
"ragex" ]
|
||||
:modes_denylist [
|
||||
:markdown
|
||||
:text
|
||||
:gitconfig
|
||||
:gitignore ]
|
||||
:delay 0 }
|
||||
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
|
||||
:IlluminatedWordText
|
||||
{}))))
|
||||
:config
|
||||
(module-call! :illuminate
|
||||
:configure { :providers [
|
||||
"lsp"
|
||||
"treesitter"
|
||||
"ragex" ]
|
||||
:filetypes_denylist [
|
||||
:Trouble
|
||||
:markdown
|
||||
:text
|
||||
:gitconfig
|
||||
:gitignore ]
|
||||
:delay 0 })
|
||||
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
|
||||
:IlluminatedWordText
|
||||
{})))
|
||||
|
||||
;; Snippy
|
||||
(use! :dcampos/nvim-snippy
|
||||
:config #(let [map (require :snippy.mapping)]
|
||||
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
|
||||
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
|
||||
:config
|
||||
(let [map (require :snippy.mapping)]
|
||||
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
|
||||
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
|
||||
|
||||
;; nvim-cmp (autocomplete)
|
||||
(use! :hrsh7th/nvim-cmp
|
||||
@ -172,18 +156,89 @@
|
||||
{ 1 :ray-x/cmp-treesitter
|
||||
:after :nvim-cmp }
|
||||
: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
|
||||
(use! :neovim/nvim-lspconfig
|
||||
:after [ :cmp-nvim-lsp
|
||||
:fzf-lua ]
|
||||
:config (module-fn! :plugin.lsp :configure))
|
||||
:after :cmp-nvim-lsp
|
||||
:config
|
||||
(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
|
||||
(use! :mfussenegger/nvim-jdtls
|
||||
:after :nvim-lspconfig
|
||||
:config (module-fn! :plugin.jdtls :configure))
|
||||
: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
|
||||
|
@ -4,85 +4,164 @@
|
||||
|
||||
{ :configure #(let [cmp (require :cmp)
|
||||
compare (require :cmp.config.compare)]
|
||||
(cmp.setup
|
||||
{ :snippet {
|
||||
:expand #(module-call! :snippy :expand_snippet $1.body) }
|
||||
:mapping {
|
||||
:<C-b> (cmp.mapping (cmp.mapping.scroll_docs -4)
|
||||
[ :i :c ])
|
||||
:<C-f> (cmp.mapping (cmp.mapping.scroll_docs 4)
|
||||
[ :i :c ])
|
||||
:<C-space> (cmp.mapping (cmp.mapping.complete)
|
||||
(cmp.setup
|
||||
{ :snippet {
|
||||
:expand #(module-call! :snippy :expand_snippet $1.body) }
|
||||
:mapping {
|
||||
:<C-b> (cmp.mapping (cmp.mapping.scroll_docs -4)
|
||||
[ :i :c ])
|
||||
:<C-f> (cmp.mapping (cmp.mapping.scroll_docs 4)
|
||||
[ :i :c ])
|
||||
:<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 ])
|
||||
:<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]" }
|
||||
entry.source.name))
|
||||
vim_item)
|
||||
}
|
||||
:sources (cmp.config.sources
|
||||
[{ :name "nvim_lsp" :priority 2 }
|
||||
{ :name "snippy" :priority 1 }
|
||||
{ :name "buffer" :priority 0 }
|
||||
{ :name "path" :priority 0 }]
|
||||
[{ :name "treesitter" :priority 2 }
|
||||
{ :name "snippy" :priority 1 }
|
||||
{ :name "buffer" :priority 0 }
|
||||
{ :name "path" :priority 0 }])
|
||||
: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.cmdline "/"
|
||||
{ :mapping (cmp.mapping.preset.cmdline)
|
||||
:sources (cmp.config.sources
|
||||
[{ :name "buffer" }])})
|
||||
:<cr> (cmp.mapping
|
||||
(cmp.mapping.confirm { :select false })
|
||||
[ :i :c ])
|
||||
:<Tab> (cmp.mapping
|
||||
(fn []
|
||||
(if (cmp.visible)
|
||||
(cmp.select_prev_item)
|
||||
(do
|
||||
(cmp.complete)
|
||||
(cmp.complete_common_string))))
|
||||
[ :i :c ])
|
||||
:<S-Tab> (cmp.mapping
|
||||
(fn []
|
||||
(if (cmp.visible)
|
||||
(cmp.select_next_item)
|
||||
(do
|
||||
(cmp.complete)
|
||||
(cmp.complete_common_string))))
|
||||
[ :i :c ])
|
||||
:<C-k> (cmp.mapping
|
||||
(fn []
|
||||
(if (cmp.visible)
|
||||
(cmp.select_prev_item
|
||||
{ :behavior cmp.SelectBehavior.Select })
|
||||
(vim.api.nvim_feedkeys
|
||||
(vim.api.nvim_replace_termcodes :<up>
|
||||
true
|
||||
false
|
||||
true)
|
||||
:n false)))
|
||||
[ :i :c ])
|
||||
:<C-j> (cmp.mapping
|
||||
(fn []
|
||||
(if (cmp.visible)
|
||||
(cmp.select_next_item
|
||||
{ :behavior cmp.SelectBehavior.Select })
|
||||
(vim.api.nvim_feedkeys
|
||||
(vim.api.nvim_replace_termcodes :<down>
|
||||
true
|
||||
false
|
||||
true)
|
||||
:n false)))
|
||||
[ :i :c ])
|
||||
:<C-p> (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 ])
|
||||
:<up> (cmp.mapping
|
||||
(fn [fallback]
|
||||
(if (cmp.visible)
|
||||
(cmp.select_prev_item
|
||||
{ :behavior cmp.SelectBehavior.Select })
|
||||
(fallback)))
|
||||
[ :i :c ])
|
||||
:<down> (cmp.mapping
|
||||
(fn [fallback]
|
||||
(if (cmp.visible)
|
||||
(cmp.select_next_item
|
||||
{ :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 ":"
|
||||
{ :mapping (cmp.mapping.preset.cmdline)
|
||||
:sources (cmp.config.sources
|
||||
[{ :name "cmdline" }
|
||||
{ :name "path" }])}))}
|
||||
{ :completion { :autocomplete false }
|
||||
:mapping cmdline-mappings
|
||||
:sources (cmp.config.sources
|
||||
[{ :name "cmdline" }])})))}
|
||||
|
@ -1,32 +1,64 @@
|
||||
;;; 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.definition buf)
|
||||
; (bind! :n :gd vim.lsp.buf.definition 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 :<leader>wa vim.lsp.buf.add_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)
|
||||
(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>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 :<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
|
||||
(let [fzf (require :fzf-lua)]
|
||||
(bind! :n :gr fzf.lsp_references buf)
|
||||
(bind! :n :<leader>s fzf.lsp_live_workspace_symbols buf)
|
||||
(bind! :n :<leader>fs fzf.lsp_live_workspace_symbols buf)
|
||||
(bind! :n :<leader>fS fzf.lsp_workspace_symbols buf)
|
||||
(bind! :n :<leader>d fzf.lsp_document_symbols buf)
|
||||
(bind! :n :<leader>fd fzf.lsp_document_symbols buf)
|
||||
(bind! :n :<leader>cn fzf.lsp_code_actions buf)))
|
||||
(bind! :n :<leader>s "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
|
||||
(bind! :n :<leader>fs "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
|
||||
(bind! :n :<leader>fS "<cmd>Telescope lsp_workspace_symbols<cr>" buf)
|
||||
;(print (vim.inspect client.server_capabilities))
|
||||
(when client.server_capabilities.documentSymbolProvider
|
||||
(bind! :n :<leader>d "<cmd>Telescope lsp_document_symbols<cr>" buf)
|
||||
(bind! :n :<leader>fd "<cmd>Telescope lsp_document_symbols<cr>" 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]
|
||||
(let [resolved_path (vim.fn.resolve root)
|
||||
@ -38,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 ...]
|
||||
@ -51,12 +83,27 @@
|
||||
(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)
|
||||
(setup-server! :sumneko_lua
|
||||
(setup-server! :pylsp)
|
||||
(setup-server! :lua_ls
|
||||
:settings {
|
||||
:Lua {
|
||||
:runtime {
|
||||
@ -68,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 }
|
||||
|
71
fnl/plugin/telescope.fnl
Normal file
71
fnl/plugin/telescope.fnl
Normal 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))) }
|
44
init.fnl
44
init.fnl
@ -1,6 +1,7 @@
|
||||
;;; init.fnl - primary init file
|
||||
|
||||
(import-macros {: bind! : module-call! : hook!} :macros)
|
||||
(import-macros {: bind! : module-call! : hook!
|
||||
: save-excursion! } :macros)
|
||||
|
||||
;; Make space leader
|
||||
(set vim.g.mapleader " ")
|
||||
@ -47,32 +48,40 @@
|
||||
(set vim.opt.undofile true)
|
||||
; Text width
|
||||
(set vim.opt.textwidth 80)
|
||||
; Spell options
|
||||
(set vim.opt.spelllang :en_us)
|
||||
; Spell optionis
|
||||
(set vim.opt.spelllang "en_us,cjk")
|
||||
(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)
|
||||
; 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 []
|
||||
"Remove trailing whitespace from the whole file."
|
||||
(let [res (pcall vim.cmd "%s/ \\+$//gc")]
|
||||
(vim.cmd.nohlsearch)
|
||||
(when (not res)
|
||||
(print "File is clean"))))
|
||||
(save-excursion!
|
||||
(vim.api.nvim_exec "keepjumps keeppatterns silent! %s/ \\+$//" false)
|
||||
(vim.api.nvim_exec "keepjumps keeppatterns silent! 0;/^\\%(\\n*.\\)\\@!/,$d_" false)))
|
||||
(vim.api.nvim_create_user_command :RemoveTrailingWhitespace
|
||||
remove-trailing-whitespace {})
|
||||
(bind! :n :<leader>ws remove-trailing-whitespace)
|
||||
(hook! [ :BufWritePre ] "*" remove-trailing-whitespace)
|
||||
|
||||
;; Spell keybindings
|
||||
(bind! :n :<leader>l (fn []
|
||||
(let [new-spell (not (vim.opt_local.spell:get))]
|
||||
(set vim.opt_local.spell new-spell)
|
||||
(print (if new-spell
|
||||
"Enabled Spellcheck"
|
||||
"Disabled Spellcheck")))))
|
||||
(let [new-spell (not (vim.opt_local.spell:get))]
|
||||
(set vim.opt_local.spell new-spell)
|
||||
(print (if new-spell
|
||||
"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)))
|
||||
@ -90,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