summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2023-12-24 18:29:48 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2023-12-24 18:29:48 -0600
commitb3d9eba21e1f1be721e86580c6b42c0a542930db (patch)
tree3ecf2d8280c28e000262739e3db7ab434cf34d78
parent372665cb43bb7cf82b87cb7ac23b79bed2b853bc (diff)
feat: add null-ls and configure, disabled for now
-rw-r--r--lua/plugins/lspconfig.lua4
-rw-r--r--lua/plugins/nonels.lua45
2 files changed, 48 insertions, 1 deletions
diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua
index 7b806e6..5523af6 100644
--- a/lua/plugins/lspconfig.lua
+++ b/lua/plugins/lspconfig.lua
@@ -1,5 +1,7 @@
local servers = {
- gopls = {},
+ gopls = {
+ gofumpt = true
+ },
-- jedi_language_server = {},
pyright = {},
lua_ls = {
diff --git a/lua/plugins/nonels.lua b/lua/plugins/nonels.lua
new file mode 100644
index 0000000..c0c27df
--- /dev/null
+++ b/lua/plugins/nonels.lua
@@ -0,0 +1,45 @@
+return {
+ "nvimtools/none-ls.nvim",
+ enabled = false,
+ dependencies = {
+ { "williamboman/mason.nvim", config = true},
+ {
+ "jay-babu/mason-null-ls.nvim",
+ event = { "BufReadPre", "BufNewFile" },
+ opts = {},
+ },
+ },
+ config = function ()
+ local mason_nullls = require('mason-null-ls')
+ mason_nullls.setup({
+ ensure_installed = {
+ 'gofumpt', -- or gofmt
+ 'golines',
+ },
+ automatic_installation = true,
+ handlers = {}
+ })
+
+ -- autoformatting on save from: https://github.com/jose-elias-alvarez/null-ls.nvim/wiki/Formatting-on-save
+ -- pretty sure this will autoformat any code
+ local nonels = require('null-ls')
+ local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
+ nonels.setup({
+ -- you can reuse a shared lspconfig on_attach callback here
+ on_attach = function(client, bufnr)
+ if client.supports_method("textDocument/formatting") then
+ vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ group = augroup,
+ buffer = bufnr,
+ callback = function()
+ -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
+ -- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead
+ vim.lsp.buf.format({async = false})
+ end,
+ })
+ end
+ end,
+ })
+ end,
+}