2022-11-29 05:22:32 -08:00
|
|
|
;;; init.fnl - primary init file
|
|
|
|
|
2022-12-31 18:18:49 -08:00
|
|
|
(import-macros {: bind! : module-call! : hook!
|
|
|
|
: save-excursion! } :macros)
|
2022-11-29 05:22:32 -08:00
|
|
|
|
|
|
|
;; Make space leader
|
|
|
|
(set vim.g.mapleader " ")
|
|
|
|
(bind! :n :<space> :<nop>)
|
|
|
|
|
2022-11-30 00:47:55 -08:00
|
|
|
;; Make comma localleader
|
|
|
|
(set vim.g.maplocalleader ",")
|
|
|
|
|
2022-11-29 05:22:32 -08:00
|
|
|
;; Enable lua filetype
|
|
|
|
(set vim.g.do_filetype_lua true)
|
|
|
|
|
|
|
|
;; Some options
|
|
|
|
; Make the mouse work
|
|
|
|
(set vim.opt.mouse :a)
|
|
|
|
(set vim.opt.mousemodel :extend)
|
|
|
|
; Ignore case when a query is all lower case
|
|
|
|
(set vim.opt.ignorecase true)
|
|
|
|
(set vim.opt.smartcase true)
|
|
|
|
; Enable line numbering
|
|
|
|
(set vim.opt.number true)
|
|
|
|
; Make <tab> insert 4 spaces
|
|
|
|
(set vim.opt.expandtab true)
|
|
|
|
(set vim.opt.tabstop 4)
|
|
|
|
(set vim.opt.shiftwidth 4)
|
|
|
|
(set vim.opt.shiftround true)
|
|
|
|
; Auto-indent
|
|
|
|
(set vim.opt.autoindent true)
|
|
|
|
(set vim.opt.smartindent true)
|
|
|
|
; Give context while scrolling
|
|
|
|
(set vim.opt.scrolloff 4)
|
|
|
|
(set vim.opt.sidescrolloff 8)
|
|
|
|
; Make splitting better
|
|
|
|
(set vim.opt.splitbelow true)
|
|
|
|
(set vim.opt.splitright true)
|
|
|
|
; 24 bit color support
|
|
|
|
(set vim.opt.termguicolors true)
|
|
|
|
; Shell like completions
|
|
|
|
(set vim.opt.wildmode [ :list :longest ])
|
|
|
|
; Set completion options
|
|
|
|
(set vim.opt.completeopt [ :menu :menuone :noselect ])
|
|
|
|
; Make buffers hide when abandoned
|
|
|
|
(set vim.opt.hidden true)
|
|
|
|
; Save undo data
|
|
|
|
(set vim.opt.undofile true)
|
|
|
|
; Text width
|
|
|
|
(set vim.opt.textwidth 80)
|
2023-02-06 12:23:45 -08:00
|
|
|
; Spell optionis
|
2023-01-26 17:01:22 -08:00
|
|
|
(set vim.opt.spelllang "en_us,cjk")
|
2022-11-29 05:22:32 -08:00
|
|
|
(set vim.opt.spelloptions :camel)
|
|
|
|
; Allow more freedom with the cursor
|
|
|
|
(set vim.opt.virtualedit :block)
|
2022-12-08 13:22:40 -08:00
|
|
|
; Disable modeline for security
|
|
|
|
(set vim.opt.modeline false)
|
|
|
|
(set vim.opt.modelines 0)
|
2022-12-10 04:59:31 -08:00
|
|
|
; Auto chdir into files' dirs
|
2022-12-10 06:44:36 -08:00
|
|
|
;(set vim.opt.autochdir true)
|
2023-02-06 12:23:45 -08:00
|
|
|
; Enable substitute 'g' flag by default
|
|
|
|
(set vim.opt.gdefault true)
|
2022-11-29 05:22:32 -08:00
|
|
|
|
|
|
|
;; Remove trailing whitespace
|
2022-12-02 16:38:31 -08:00
|
|
|
(fn remove-trailing-whitespace []
|
2022-11-29 05:22:32 -08:00
|
|
|
"Remove trailing whitespace from the whole file."
|
2022-12-31 18:18:49 -08:00
|
|
|
(save-excursion!
|
|
|
|
(vim.api.nvim_exec "keepjumps keeppatterns silent! %s/ \\+$//" false)
|
|
|
|
(vim.api.nvim_exec "keepjumps keeppatterns silent! 0;/^\\%(\\n*.\\)\\@!/,$d_" false)))
|
2022-11-29 05:22:32 -08:00
|
|
|
(vim.api.nvim_create_user_command :RemoveTrailingWhitespace
|
2022-12-02 16:38:31 -08:00
|
|
|
remove-trailing-whitespace {})
|
2022-12-09 00:23:02 -08:00
|
|
|
(hook! [ :BufWritePre ] "*" remove-trailing-whitespace)
|
2022-11-29 05:22:32 -08:00
|
|
|
|
|
|
|
;; Spell keybindings
|
|
|
|
(bind! :n :<leader>l (fn []
|
2022-12-10 04:59:31 -08:00
|
|
|
(let [new-spell (not (vim.opt_local.spell:get))]
|
|
|
|
(set vim.opt_local.spell new-spell)
|
|
|
|
(print (if new-spell
|
|
|
|
"Enabled Spellcheck"
|
|
|
|
"Disabled Spellcheck")))))
|
2022-11-29 05:22:32 -08:00
|
|
|
|
2022-12-02 19:22:59 -08:00
|
|
|
;; Enable spell in certian buffers
|
2022-12-10 06:44:36 -08:00
|
|
|
(hook! :FileType [ :text :markdown :tex :bib ]
|
2022-12-02 19:22:59 -08:00
|
|
|
#(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1)
|
|
|
|
(set vim.opt_local.spell true)))
|
|
|
|
|
2022-11-29 05:22:32 -08:00
|
|
|
;; Some keybindings for diagnostics
|
|
|
|
(bind! :n :<leader>e vim.diagnostic.open_float)
|
|
|
|
(bind! :n "[d" vim.diagnostic.goto_prev)
|
|
|
|
(bind! :n "]d" vim.diagnostic.goto_next)
|
|
|
|
(bind! :n :<leader>q vim.diagnostic.setloclist)
|
|
|
|
|
2022-11-29 23:55:20 -08:00
|
|
|
;; Some filetype settings
|
|
|
|
(vim.filetype.add { :filename {
|
|
|
|
".latexmkrc" :perl
|
|
|
|
"Jenkinsfile" :groovy }
|
2022-12-06 10:58:47 -08:00
|
|
|
:extension {
|
2022-11-29 23:55:20 -08:00
|
|
|
"nasm" :nasm
|
|
|
|
"h" :c
|
|
|
|
"ui" :xml }})
|
|
|
|
|
2022-11-30 23:34:15 -08:00
|
|
|
(module-call! :packer :startup (require :plugin))
|