summaryrefslogtreecommitdiff
path: root/fnl/conf
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2023-01-02 11:37:20 +0100
committerMike Vink <mike1994vink@gmail.com>2023-01-02 11:38:02 +0100
commite107ac067ebd4aedebd8ec9cde5ece7a38acad02 (patch)
tree9e7a56aadfc80e895931dd6b13a016fc149aa9e0 /fnl/conf
parent042072d6b96d6072d260d1b61cf9e770f1c2890e (diff)
added trim whitespace autocommand
Diffstat (limited to 'fnl/conf')
-rw-r--r--fnl/conf/diagnostic.fnl5
-rw-r--r--fnl/conf/events.fnl46
-rw-r--r--fnl/conf/init.fnl7
-rw-r--r--fnl/conf/lsp.fnl20
4 files changed, 53 insertions, 25 deletions
diff --git a/fnl/conf/diagnostic.fnl b/fnl/conf/diagnostic.fnl
new file mode 100644
index 0000000..b88a3d5
--- /dev/null
+++ b/fnl/conf/diagnostic.fnl
@@ -0,0 +1,5 @@
+(fn m [mode key cb]
+ (vim.keymap.set mode key cb {:silent true :noremap true}))
+
+(m :n :<leader>ge (fn []
+ (vim.diagnostic.open_float)))
diff --git a/fnl/conf/events.fnl b/fnl/conf/events.fnl
index 082a274..997bf63 100644
--- a/fnl/conf/events.fnl
+++ b/fnl/conf/events.fnl
@@ -1,13 +1,35 @@
-;; vim.cmd([[augroup vimrc_plugin_buffers]])
-;; vim.cmd([[au!]])
-;; vim.cmd(
-;; [[autocmd BufWritePre *.md,*.hcl,*.tf,*.py,*.cpp,*.qml,*.js,*.txt,*.json,*.html,*.lua,*.yaml,*.yml,*.bash,*.sh,*.go :lua require"vimrc.buffers".clean_trailing_spaces()]])
-;;
-;; vim.cmd(
-;; [[autocmd BufReadPost * lua require"vimrc.buffers".setup_white_space_highlight(vim.fn.bufnr())]])
-;;
-;; vim.cmd(
-;; [[autocmd BufReadPre *.tf,*.hcl packadd vim-terraform]])
-;;
-;; vim.cmd([[augroup END]])
+(vim.api.nvim_create_augroup "conf#events" {:clear true})
+(let [white_space_highlight (fn []
+ (local pattern "'\\s\\+$'")
+ (vim.cmd (.. "syn match TrailingWhitespace "
+ pattern))
+ (vim.cmd "hi link TrailingWhitespace IncSearch"))
+ trim [:*.fnl
+ :*.md
+ :*.hcl
+ :*.tf
+ :*.py
+ :*.cpp
+ :*.qml
+ :*.js
+ :*.txt
+ :*.json
+ :*.html
+ :*.lua
+ :*.yaml
+ :*.yml
+ :*.bash
+ :*.sh
+ :*.go]
+ white_space_trim (fn []
+ (local pattern "\\s\\+$")
+ (vim.cmd (.. :%substitute/ pattern ://ge)))]
+ (vim.api.nvim_create_autocmd [:BufReadPost]
+ {:pattern ["*"]
+ :callback white_space_highlight
+ :group "conf#events"})
+ (vim.api.nvim_create_autocmd [:BufWritePre]
+ {:pattern trim
+ :callback white_space_trim
+ :group "conf#events"}))
diff --git a/fnl/conf/init.fnl b/fnl/conf/init.fnl
index 388139f..40b7210 100644
--- a/fnl/conf/init.fnl
+++ b/fnl/conf/init.fnl
@@ -3,6 +3,9 @@
(vim.cmd "filetype indent on")
(vim.cmd "highlight WinSeparator guibg=None")
-(require :conf.lsp)
-(require :conf.pkgs)
(require :conf.settings)
+(require :conf.pkgs)
+(require :conf.lsp)
+(require :conf.events)
+
+(require :conf.diagnostic)
diff --git a/fnl/conf/lsp.fnl b/fnl/conf/lsp.fnl
index 596d731..6d81d7a 100644
--- a/fnl/conf/lsp.fnl
+++ b/fnl/conf/lsp.fnl
@@ -21,17 +21,15 @@
:codeActionProvider (bm :n :<leader>ga (lspdo :code_action))
:hoverProvider (bo :keywordprg ":LspHover")
:documentRangeFormattingProvider
- (if format (bm :v :<leader>gq (lspdo :range_formatting)))
- :documentFormattingProvider (if format
- ((fn []
- (bo :formatexpr
- "v:lua.vim.lsp.format()")
- (bm :n :<leader>gq
- #(vim.lsp.buf.format {:async true})))))))
-
- (each [cpb enabled? (pairs client.server_capabilities)]
- (if enabled?
- (use cpb))))
+ (if format (bm :v :<leader>gq (lspdo :range_formatting))
+ :documentFormattingProvider
+ (if format
+ ((fn []
+ (bo :formatexpr "v:lua.vim.lsp.format()"
+ (bm :n :<leader>gq #(vim.lsp.buf.format {:async true}))))))
+ (each [cpb enabled? (pairs client.server_capabilities)]
+ (if enabled?
+ (use cpb)))))))
(fn attach [client buf format]
(fn P [p]