Skip to content

Commit

Permalink
Initial configuration for golang editing
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamenisch committed Apr 5, 2024
1 parent 8fa4748 commit 2f8e6a0
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 37 deletions.
3 changes: 2 additions & 1 deletion nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "9d5ba06d6ee7418c674f498634617416d15b6239" },
"friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" },
"gitsigns.nvim": { "branch": "main", "commit": "320b232fb458f6c8b2467e3ef9b49034617a2a78" },
"gitsigns.nvim": { "branch": "main", "commit": "81369ed5405ec0c5d55a9608b495dbf827415116" },
"indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" },
"lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
"nvim-autopairs": { "branch": "master", "commit": "dbfc1c34bed415906395db8303c71039b3a3ffb4" },
"nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
Expand Down
14 changes: 2 additions & 12 deletions nvim/lua/chadrc.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
-- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/NvChad/blob/v2.5/lua/nvconfig.lua

---@type ChadrcConfig
local M = {}

M.ui = {
theme = "everblush",

-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
}
M.ui = {theme = "everblush"}
M.plugins = 'plugins'

return M
18 changes: 18 additions & 0 deletions nvim/lua/configs/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ lspconfig.tsserver.setup {
on_init = on_init,
capabilities = capabilities,
}

-- golang
lspconfig.gopls.setup {
on_attach = on_attach,
capabilities = capabilities,
cmd = {"gopls"},
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_dir = lspconfig.util.root_pattern("go.work", "go.mod", ".git"),
settings = {
gopls = {
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
}
}
}
}
26 changes: 26 additions & 0 deletions nvim/lua/configs/null-ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local null_ls = require("null-ls")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})

local opts = {
sources = {
null_ls.builtins.formatting.gofmt,
null_ls.builtins.formatting.goimports,
},
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
6 changes: 0 additions & 6 deletions nvim/lua/custom/chadrc.lua

This file was deleted.

Empty file removed nvim/lua/custom/plugins.lua
Empty file.
3 changes: 2 additions & 1 deletion nvim/lua/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ require "nvchad.mappings"

local map = vim.keymap.set

map("n", ";", ":", { desc = "CMD enter command mode" })
map("n", "-", "<cmd>NvimTreeToggle<CR>")

map("i", "jj", "<ESC>")

-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")
44 changes: 27 additions & 17 deletions nvim/lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,35 @@ return {
require "configs.conform"
end,
},
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"lua-language-server",
"stylua",
"gopls",
"html-lsp",
"css-lsp" ,
"prettier"
}
},
{
"neovim/nvim-lspconfig",
config = function()
require("nvchad.configs.lspconfig").defaults()
require "configs.lspconfig"
end,
},
{
"jose-elias-alvarez/null-ls.nvim",
ft = "go",
opts = function()
return require "configs.null-ls"
end,
},
},

-- These are some examples, uncomment them if you want to see them work!
-- {
-- "neovim/nvim-lspconfig",
-- config = function()
-- require("nvchad.configs.lspconfig").defaults()
-- require "configs.lspconfig"
-- end,
-- },
--
-- {
-- "williamboman/mason.nvim",
-- opts = {
-- ensure_installed = {
-- "lua-language-server", "stylua",
-- "html-lsp", "css-lsp" , "prettier"
-- },
-- },
-- },
--
-- {
-- "nvim-treesitter/nvim-treesitter",
Expand Down

0 comments on commit 2f8e6a0

Please sign in to comment.