From ea3ef7021495a68ae226ad752ecd3b1ecaa2ab07 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 2 Dec 2022 19:22:59 -0800 Subject: [PATCH] Clean up names and make spellcheck default for text bufs --- fnl/plugin.fnl | 6 +++--- fnl/plugin/jdtls.fnl | 10 +++++----- fnl/plugin/lsp.fnl | 34 +++++++++++++++++----------------- init.fnl | 13 +++++++++---- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/fnl/plugin.fnl b/fnl/plugin.fnl index b6a8531..da2edc7 100644 --- a/fnl/plugin.fnl +++ b/fnl/plugin.fnl @@ -116,12 +116,12 @@ :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)] + (let [find-other (require :nvim-find-other)] (vim.api.nvim_create_user_command "FindOtherFile" - find_other.find_other_current_buffer + find-other.find_other_current_buffer {}) - (bind! :n :go find_other.find_other_current_buffer)))) + (bind! :n :go find-other.find_other_current_buffer)))) (use! :RRethy/vim-illuminate :config (fn [] diff --git a/fnl/plugin/jdtls.fnl b/fnl/plugin/jdtls.fnl index 2fb3de5..8eef09d 100644 --- a/fnl/plugin/jdtls.fnl +++ b/fnl/plugin/jdtls.fnl @@ -4,17 +4,17 @@ (fn configure [] (hook! :FileType :java - #(let [root_dir (module-call! :jdtls.setup :find_root + #(let [root-dir (module-call! :jdtls.setup :find_root [ ".git" "mvnw" "gradlew" "build.gradle" ]) - lsp_cap (module-call! :cmp_nvim_lsp :default_capabilities)] + lsp-cap (module-call! :cmp_nvim_lsp :default_capabilities)] (module-call! :jdtls :start_or_attach - { :capabilities lsp_cap + { :capabilities lsp-cap :on_attach (module-fn! :plugin.lsp :on-attach) - :root_dir root_dir + :root_dir root-dir :cmd [ "jdtls" "-data" (module-call! :plugin.lsp :get-data-dir - :jdtls root_dir) ]})))) + :jdtls root-dir) ]})))) {: configure} diff --git a/fnl/plugin/lsp.fnl b/fnl/plugin/lsp.fnl index ca50ad1..df44a35 100644 --- a/fnl/plugin/lsp.fnl +++ b/fnl/plugin/lsp.fnl @@ -39,24 +39,24 @@ (fn configure [] (let [lsp (require :lspconfig) configs (require :lspconfig.configs) - lsp_cap ((. (require :cmp_nvim_lsp) :default_capabilities)) - lsp_utils (require :plugin.lsp)] - (macro setup_server! [name ...] - (let [opts { :on-attach `lsp_utils.on_attach - :capabilities `lsp_cap }] - (var last_key nil) + lsp-cap ((. (require :cmp_nvim_lsp) :default_capabilities)) + lsp-utils (require :plugin.lsp)] + (macro setup-server! [name ...] + (let [opts { :on-attach `lsp-utils.on-attach + :capabilities `lsp-cap }] + (var last-key nil) (each [_ val (ipairs [...])] - (if last_key - (do (tset opts last_key val) - (set last_key nil)) - (set last_key val))) + (if last-key + (do (tset opts last-key val) + (set last-key nil)) + (set last-key val))) `((. (. lsp ,name) :setup) ,opts))) - (setup_server! :ccls) - (setup_server! :cmake) - (setup_server! :gopls) - (setup_server! :rust_analyzer) - (setup_server! :texlab) - (setup_server! :sumneko_lua + (setup-server! :ccls) + (setup-server! :cmake) + (setup-server! :gopls) + (setup-server! :rust_analyzer) + (setup-server! :texlab) + (setup-server! :sumneko_lua :settings { :Lua { :runtime { @@ -82,6 +82,6 @@ :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)))) { : configure : on-attach : get-data-dir } diff --git a/init.fnl b/init.fnl index f325d8f..f20c8eb 100644 --- a/init.fnl +++ b/init.fnl @@ -1,6 +1,6 @@ ;;; init.fnl - primary init file -(import-macros {: bind! : module-call!} :macros) +(import-macros {: bind! : module-call! : hook!} :macros) ;; Make space leader (set vim.g.mapleader " ") @@ -70,12 +70,17 @@ ;; Spell keybindings (bind! :n :l (fn [] - (let [new_spell (not (vim.opt_local.spell:get))] - (set vim.opt_local.spell new_spell) - (print (if new_spell + (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))) + (fn jump-or-open-terminal [] "If no terminal buffer exists, create one. Otherwise, open new one." (var term_count 0)