From 3092193f366b0ffff3fa6fbc772ec9e505187829 Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Thu, 20 Nov 2025 11:13:34 -0600 Subject: conform --- nvim/init.lua | 83 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index df1c46e..bde9fd6 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,8 +1,3 @@ -vim.opt.tabstop = 2 -vim.opt.softtabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.expandtab = true - vim.keymap.set('n', '', ':w', { noremap = true, silent = true }) vim.keymap.set('i', '', ':w', { noremap = true, silent = true }) vim.keymap.set('v', '', ':wgv', { noremap = true, silent = true }) @@ -13,19 +8,19 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " vim.api.nvim_create_autocmd("LspAttach", { - desc = "LSP actions", - callback = function(event) - local opts = { buffer = event.buf } - - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - - -- Diagnostics (optional but helpful) - vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) - end, + desc = "LSP actions", + callback = function(event) + local opts = { buffer = event.buf } + + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + + -- Diagnostics (optional but helpful) + vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) + end, }) local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" @@ -91,23 +86,43 @@ require("lazy").setup({ { "williamboman/mason.nvim", dependencies = { - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", }, config = function() - require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } - }) - - require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls" }, - }) + require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } + }) + + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls" }, + }) end - } + }, + + { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + keys = { + { "fm", function() require("conform").format() end, desc = "Format file" }, + }, + opts = { + formatters_by_ft = { + go = { "goimports" }, + }, + + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }, + }, + dependencies = { "mason.nvim" }, + }, }) -- cgit v1.2.3