From 3070940cd199734af885ca9aed0f64b509ed85ef Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Tue, 25 Apr 2023 21:00:23 +0100 Subject: [PATCH] feat(core): start on the clojure journey Install all of the tools and config for clojure development. This adds the first configz module that is not yet properly integrated and automaticaly run with the `dotfiles` shell command. --- .gitignore | 1 - modules/clojure.lua | 36 +++++++++++++++++++ site-modules/core/files/vim/init.vim | 1 + site-modules/core/files/vim/plugin/lint.lua | 7 +++- site-modules/core/files/vim/plugin/lsp.lua | 1 + .../core/files/vim/plugin/treesitter.lua | 4 +-- site-modules/core/manifests/vim.pp | 1 + 7 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 modules/clojure.lua diff --git a/.gitignore b/.gitignore index 99318fb..3079c79 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ # Edit at https://www.toptal.com/developers/gitignore?templates=puppet,emacs,code,vim,linux ### Application ### -modules .resource_types info.rb .rerun.json diff --git a/modules/clojure.lua b/modules/clojure.lua new file mode 100644 index 0000000..1bc8558 --- /dev/null +++ b/modules/clojure.lua @@ -0,0 +1,36 @@ +-- Configz module for the clojure dev tools + +local function install_clojure_lsp() + configz.download("/tmp/closure-lsp.zip", { + sha256 = "c23a5c9029b3a548a6b8e66a0662103c13e44f220ad8e3f97abf0b7c53a994b1", + url = "https://github.com/clojure-lsp/clojure-lsp/releases/download/2023.02.27-13.12.12/clojure-lsp-native-static-linux-amd64.zip", + }) + + configz.run "cd /tmp; unzip /tmp/closure-lsp.zip" + configz.file(os.getenv "HOME" .. "/.local/bin/clojure-lsp", { source = "/tmp/clojure-lsp" }) +end + +local function has_correct_version(command, version) + local ok, _ = configz.run(command .. " --version | grep " .. version) + return ok +end + +local clojure_lsp_installed, clojure_lsp = configz.get_executable "clojure-lsp" +if not clojure_lsp_installed or not has_correct_version(clojure_lsp, "2023.02.27-13.12.12") then + install_clojure_lsp() +end + +local function install_babashka() + configz.download("/tmp/babashka.tar.gz", { + sha256 = "46c866c28ea9d99a5544c75c554b0c1e22edfa20843d927d3c175b7021ca7252", + url = "https://github.com/babashka/babashka/releases/download/v1.3.176/babashka-1.3.176-linux-amd64.tar.gz", + }) + + configz.run "cd /tmp; tar -xzf babashka.tar.gz" + configz.file(os.getenv "HOME" .. "/.local/bin/bb", { source = "/tmp/bb" }) +end + +local bb_installed, bb = configz.get_executable "bb" +if not bb_installed or not has_correct_version(bb, "1.3.176") then + install_babashka() +end diff --git a/site-modules/core/files/vim/init.vim b/site-modules/core/files/vim/init.vim index 3a5a533..ffda289 100644 --- a/site-modules/core/files/vim/init.vim +++ b/site-modules/core/files/vim/init.vim @@ -1,5 +1,6 @@ " Set leader as space bar let mapleader="\" +let maplocalleader="\" " Use the system clipboard with yank and paste set clipboard=unnamedplus diff --git a/site-modules/core/files/vim/plugin/lint.lua b/site-modules/core/files/vim/plugin/lint.lua index 8a10525..6861bc1 100644 --- a/site-modules/core/files/vim/plugin/lint.lua +++ b/site-modules/core/files/vim/plugin/lint.lua @@ -81,7 +81,12 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { desc = "Lint the buffer", pattern = "*", callback = function() - lint.try_lint('cspell') + -- Only try and run spell checking on buffers that have a filetype. This is + -- mainly to disable spell checking in vim lsp popup buffers. + if vim.bo.filetype ~= "" then + lint.try_lint('cspell') + end + lint.try_lint() end, }) diff --git a/site-modules/core/files/vim/plugin/lsp.lua b/site-modules/core/files/vim/plugin/lsp.lua index 3c0317f..2f53be9 100644 --- a/site-modules/core/files/vim/plugin/lsp.lua +++ b/site-modules/core/files/vim/plugin/lsp.lua @@ -14,6 +14,7 @@ local servers = { }, html = {}, cssls = {}, + clojure_lsp = {}, emmet_ls = { filetypes = { "html", "typescriptreact", "javascriptreact", "css", "scss", "eruby" }, }, diff --git a/site-modules/core/files/vim/plugin/treesitter.lua b/site-modules/core/files/vim/plugin/treesitter.lua index 218a6e7..ee897c7 100644 --- a/site-modules/core/files/vim/plugin/treesitter.lua +++ b/site-modules/core/files/vim/plugin/treesitter.lua @@ -6,7 +6,7 @@ require'nvim-treesitter.configs'.setup { enable = true, additional_vim_regex_highlighting = true, }, - ensure_installed = { - "typescript", "javascript", "tsx", "php", "html", "go", "org" + ensure_installed = { + "typescript", "javascript", "tsx", "php", "html", "go", "org", "clojure" }, } diff --git a/site-modules/core/manifests/vim.pp b/site-modules/core/manifests/vim.pp index 6c58c4d..8d87f64 100644 --- a/site-modules/core/manifests/vim.pp +++ b/site-modules/core/manifests/vim.pp @@ -61,6 +61,7 @@ class core::vim { 'vim-tmux-navigator' => { url => 'https://github.com/christoomey/vim-tmux-navigator.git' }, 'vim-fugitive' => { url => 'https://github.com/tpope/vim-fugitive.git' }, 'vim-rhubarb' => { url => 'https://github.com/tpope/vim-rhubarb.git' }, + 'conjure' => { url => 'https://github.com/Olical/conjure.git' } } create_resources(core::vim::plugin_start, $plugins_start)