add nvchad config

This commit is contained in:
Gabriel Augendre 2024-02-17 14:33:09 +01:00
parent 0e92578ee8
commit 66fe51d05f
6 changed files with 174 additions and 0 deletions

View file

@ -0,0 +1,4 @@
function vim --wraps=nvim --description 'alias vim nvim'
nvim $argv
end

View file

@ -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

View file

@ -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,
}
}
}
}

View file

@ -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

View file

@ -0,0 +1,51 @@
local M = {}
M.dap = {
plugin = true,
n = {
["<leader>db"] = {
"<cmd> DapToggleBreakpoint <CR>",
"Add breakpoint at line"
},
["<leader>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 = {
["<leader>dgt"] = {
function()
require("dap-go").debug_test()
end,
"Debug go test"
},
["<leader>dgl"] = {
function()
require("dap-go").debug_last()
end,
"Debug last go test"
},
}
}
M.terminal = {
t = {
["<Esc>"] = {"<C-\\><C-n>"}
}
}
M.general = {
i = {
["<C-a>"] = { "<ESC>^i", "Beginning of line" },
}
}
return M

View file

@ -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