From 66fe51d05f3146409c090aaa9ba14694f8dc0e90 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 17 Feb 2024 14:33:09 +0100 Subject: [PATCH] add nvchad config --- dot_config/fish/private_functions/vim.fish | 4 ++ dot_config/nvim/lua/custom/chadrc.lua | 19 +++++++ .../nvim/lua/custom/configs/lspconfig.lua | 23 +++++++++ .../nvim/lua/custom/configs/null-ls.lua | 27 ++++++++++ dot_config/nvim/lua/custom/mappings.lua | 51 +++++++++++++++++++ dot_config/nvim/lua/custom/plugins.lua | 50 ++++++++++++++++++ 6 files changed, 174 insertions(+) create mode 100644 dot_config/fish/private_functions/vim.fish create mode 100644 dot_config/nvim/lua/custom/chadrc.lua create mode 100644 dot_config/nvim/lua/custom/configs/lspconfig.lua create mode 100644 dot_config/nvim/lua/custom/configs/null-ls.lua create mode 100644 dot_config/nvim/lua/custom/mappings.lua create mode 100644 dot_config/nvim/lua/custom/plugins.lua diff --git a/dot_config/fish/private_functions/vim.fish b/dot_config/fish/private_functions/vim.fish new file mode 100644 index 0000000..67df688 --- /dev/null +++ b/dot_config/fish/private_functions/vim.fish @@ -0,0 +1,4 @@ +function vim --wraps=nvim --description 'alias vim nvim' + nvim $argv + +end diff --git a/dot_config/nvim/lua/custom/chadrc.lua b/dot_config/nvim/lua/custom/chadrc.lua new file mode 100644 index 0000000..7521880 --- /dev/null +++ b/dot_config/nvim/lua/custom/chadrc.lua @@ -0,0 +1,19 @@ +---@type ChadrcConfig +local M = {} + +M.plugins = "custom.plugins" +M.mappings = require "custom.mappings" + +M.ui = { + theme = "catppuccin", + statusline = { + theme = "default", + separator_style = "arrow", + }, + tabufline = { + lazyload = false, + show_numbers = true, + }, +} + +return M diff --git a/dot_config/nvim/lua/custom/configs/lspconfig.lua b/dot_config/nvim/lua/custom/configs/lspconfig.lua new file mode 100644 index 0000000..0fd21a0 --- /dev/null +++ b/dot_config/nvim/lua/custom/configs/lspconfig.lua @@ -0,0 +1,23 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require("lspconfig") +local util = require "lspconfig/util" + +lspconfig.gopls.setup { + on_attach = on_attach, + capabilities = capabilities, + cmd = {"gopls"}, + filetypes = {"go", "gomod", "gowork", "gotmpl"}, + root_dir = util.root_pattern("go.work", "go.mod", ".git"), + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + } + } + } +} + diff --git a/dot_config/nvim/lua/custom/configs/null-ls.lua b/dot_config/nvim/lua/custom/configs/null-ls.lua new file mode 100644 index 0000000..237996e --- /dev/null +++ b/dot_config/nvim/lua/custom/configs/null-ls.lua @@ -0,0 +1,27 @@ +local null_ls = require("null-ls") +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local opts = { + sources = { -- run these on save + null_ls.builtins.formatting.gofumpt, + null_ls.builtins.formatting.goimports_reviser, + null_ls.builtins.formatting.golines, + }, + 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() + vim.lsp.buf.format({bufnr = bufnr}) + end, + }) + end + end, +} + +return opts diff --git a/dot_config/nvim/lua/custom/mappings.lua b/dot_config/nvim/lua/custom/mappings.lua new file mode 100644 index 0000000..73a9dc8 --- /dev/null +++ b/dot_config/nvim/lua/custom/mappings.lua @@ -0,0 +1,51 @@ +local M = {} + +M.dap = { + plugin = true, + n = { + ["db"] = { + " DapToggleBreakpoint ", + "Add breakpoint at line" + }, + ["dus"] = { + function () + local widgets = require('dap.ui.widgets'); + local sidebar = widgets.sidebar(widgets.scopes); + sidebar.open(); + end, + "Open debugging sidebar" + } + } +} + +M.dap_go = { + plugin = true, + n = { + ["dgt"] = { + function() + require("dap-go").debug_test() + end, + "Debug go test" + }, + ["dgl"] = { + function() + require("dap-go").debug_last() + end, + "Debug last go test" + }, + } +} + +M.terminal = { + t = { + [""] = {""} + } +} + +M.general = { + i = { + [""] = { "^i", "Beginning of line" }, + } +} + +return M diff --git a/dot_config/nvim/lua/custom/plugins.lua b/dot_config/nvim/lua/custom/plugins.lua new file mode 100644 index 0000000..af1a945 --- /dev/null +++ b/dot_config/nvim/lua/custom/plugins.lua @@ -0,0 +1,50 @@ +local plugins = { + { + "williamboman/mason.nvim", -- auto install tools + opts = { + ensure_installed = { + "gopls", + }, + }, + }, + { + "mfussenegger/nvim-dap", -- generic debugger integration + init = function() + require("core.utils").load_mappings("dap") + end, + }, + { + "leoluz/nvim-dap-go", -- specific go debugger integration + ft = "go", + dependencies = "mfussenegger/nvim-dap", + config = function(_, opts) + require("dap-go").setup(opts) + require("core.utils").load_mappings("dap_go") + end, + }, + { + "neovim/nvim-lspconfig", -- load custom lsp config + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, + }, + { + "jose-elias-alvarez/null-ls.nvim", -- custom format on save + ft = "go", + opts = function() + return require "custom.configs.null-ls" + end, + }, + { + "olexsmir/gopher.nvim", + ft = "go", + config = function(_, opts) + require("gopher").setup(opts) + end, + build = function() + vim.cmd [[silent! GoInstallDeps]] + end, + } +} +return plugins