From e9fe358191128f79cc8f4674fdf7a368b9a1e55b Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 2 Dec 2024 08:13:10 +0100 Subject: [PATCH] Lisp support and so on --- lua/autocmd.lua | 12 ++++++++++++ lua/plugins/conjure.lua | 26 ++++++++++++++++++++++++++ lua/plugins/nvim-lspconfig.lua | 1 + lua/plugins/nvim-metals.lua | 26 ++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 lua/plugins/conjure.lua create mode 100644 lua/plugins/nvim-metals.lua diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 58256e3..802b83f 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -38,4 +38,16 @@ vim.api.nvim_create_user_command('CDToGitRoot', function() end end, { desc = 'Change directory to the current Git repository root' }) +vim.api.nvim_create_user_command('WordCount', function() + local buf = vim.api.nvim_get_current_buf() + local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) + local words = 0 + for _, line in ipairs(lines) do + for _ in line:gmatch '%S+' do + words = words + 1 + end + end + print('Word count: ' .. words) +end, { desc = 'Count words in current buffer' }) + -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/plugins/conjure.lua b/lua/plugins/conjure.lua new file mode 100644 index 0000000..e54c619 --- /dev/null +++ b/lua/plugins/conjure.lua @@ -0,0 +1,26 @@ +return { + { + "Olical/conjure", + ft = { "clojure", "fennel", "python", "janet" }, -- etc + lazy = true, + init = function() + -- Set configuration options here + -- Uncomment this to get verbose logging to help diagnose internal Conjure issues + -- This is VERY helpful when reporting an issue with the project + -- vim.g["conjure#debug"] = true + end, + + -- Optional cmp-conjure integration + dependencies = { "PaterJason/cmp-conjure" }, + }, + { + "PaterJason/cmp-conjure", + lazy = true, + config = function() + local cmp = require("cmp") + local config = cmp.get_config() + table.insert(config.sources, { name = "conjure" }) + return cmp.setup(config) + end, + }, +} diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua index 5af83af..018ee7c 100644 --- a/lua/plugins/nvim-lspconfig.lua +++ b/lua/plugins/nvim-lspconfig.lua @@ -24,6 +24,7 @@ return { -- LSP Configuration & Plugins -- Manual config for Nushell LSP -- TODO: Remove once `mason-lspconfig` supports Nushell require('lspconfig').nushell.setup {} + require('lspconfig').janet_lsp.setup {} -- Brief aside: **What is LSP?** -- diff --git a/lua/plugins/nvim-metals.lua b/lua/plugins/nvim-metals.lua new file mode 100644 index 0000000..853aa96 --- /dev/null +++ b/lua/plugins/nvim-metals.lua @@ -0,0 +1,26 @@ +return { + 'scalameta/nvim-metals', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + ft = { 'scala', 'sbt', 'java' }, + opts = function() + local metals_config = require('metals').bare_config() + metals_config.on_attach = function(client, bufnr) + -- your on_attach function + vim.keymap.set('n', 'K', vim.lsp.buf.hover) + end + + return metals_config + end, + config = function(self, metals_config) + local nvim_metals_group = vim.api.nvim_create_augroup('nvim-metals', { clear = true }) + vim.api.nvim_create_autocmd('FileType', { + pattern = self.ft, + callback = function() + require('metals').initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + end, +}