This repository has been archived on 2024-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
nvim-config/init.fnl

103 lines
3.0 KiB
Fennel

;;; init.fnl - primary init file
(import-macros {: bind! : module-call! : hook!} :macros)
;; Make space leader
(set vim.g.mapleader " ")
(bind! :n :<space> :<nop>)
;; Make comma localleader
(set vim.g.maplocalleader ",")
;; 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)
; Spell options
(set vim.opt.spelllang :en_us)
(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)
; Auto chdir into files' dirs
;(set vim.opt.autochdir true)
;; Remove trailing whitespace
(fn remove-trailing-whitespace []
"Remove trailing whitespace from the whole file."
(pcall vim.cmd "%s/ \\+$//")
(vim.cmd.nohlsearch))
(vim.api.nvim_create_user_command :RemoveTrailingWhitespace
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")))))
;; Enable spell in certian buffers
(hook! :FileType [ :text :markdown :tex :bib ]
#(if (= (vim.fn.buflisted (vim.api.nvim_get_current_buf)) 1)
(set vim.opt_local.spell true)))
;; 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)
;; Some filetype settings
(vim.filetype.add { :filename {
".latexmkrc" :perl
"Jenkinsfile" :groovy }
:extension {
"nasm" :nasm
"h" :c
"ui" :xml }})
;; Better fennel formatting
(hook! :FileType [ :fennel ]
#(set vim.opt_local.formatprg "fnlfmt -"))
(module-call! :packer :startup (require :plugin))