diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 1d841e9..97a3bc2 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -1,16 +1,16 @@ --- This file needs to have same structure as nvconfig.lua +-- 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 = "onedark", + theme = "yoru", - -- hl_override = { - -- Comment = { italic = true }, - -- ["@comment"] = { italic = true }, - -- }, + hl_override = { + Comment = { italic = true }, + ["@comment"] = { italic = true }, + }, } return M diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index a000447..e5eaddc 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -1,15 +1,15 @@ local options = { formatters_by_ft = { lua = { "stylua" }, - -- css = { "prettier" }, - -- html = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, }, - -- format_on_save = { - -- -- These options will be passed to conform.format() - -- timeout_ms = 500, - -- lsp_fallback = true, - -- }, + format_on_save = { + -- These options will be passed to conform.format() + timeout_ms = 500, + lsp_fallback = true, + }, } require("conform").setup(options) diff --git a/lua/configs/go.lua b/lua/configs/go.lua new file mode 100644 index 0000000..7f158a8 --- /dev/null +++ b/lua/configs/go.lua @@ -0,0 +1 @@ +require("go").setup() diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index a73657a..863f0dc 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -1,10 +1,10 @@ --- EXAMPLE +-- EXAMPLE local on_attach = require("nvchad.configs.lspconfig").on_attach local on_init = require("nvchad.configs.lspconfig").on_init local capabilities = require("nvchad.configs.lspconfig").capabilities local lspconfig = require "lspconfig" -local servers = { "html", "cssls" } +local servers = { "html", "cssls", "gopls" } -- lsps with default config for _, lsp in ipairs(servers) do diff --git a/lua/options.lua b/lua/options.lua index 7bd2fca..fe818df 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,12 +1,12 @@ require "nvchad.options" -- add yours here! -vim.opt.mouse='' +vim.opt.mouse = "" vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { once = true, callback = function() - if vim.fn.has("win32") == 1 or vim.fn.has("wsl") == 1 then + if vim.fn.has "win32" == 1 or vim.fn.has "wsl" == 1 then vim.g.clipboard = { copy = { ["+"] = "win32yank.exe -i --crlf", @@ -17,8 +17,8 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { ["*"] = "win32yank.exe -o --lf", }, } - elseif vim.fn.has("unix") == 1 then - if vim.fn.executable("xclip") == 1 then + elseif vim.fn.has "unix" == 1 then + if vim.fn.executable "xclip" == 1 then vim.g.clipboard = { copy = { ["+"] = "xclip -selection clipboard", @@ -29,7 +29,7 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { ["*"] = "xclip -selection clipboard -o", }, } - elseif vim.fn.executable("xsel") == 1 then + elseif vim.fn.executable "xsel" == 1 then vim.g.clipboard = { copy = { ["+"] = "xsel --clipboard --input", @@ -47,5 +47,16 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { end, desc = "Lazy load clipboard", }) --- local o = vim.o --- o.cursorlineopt ='both' -- to enable cursorline! + +-- go.nvim opts +local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, +}) + +local o = vim.o +o.cursorlineopt = "both" -- to enable cursorline! diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index e62d896..815c389 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,31 +1,52 @@ return { { "stevearc/conform.nvim", - -- event = 'BufWritePre', -- uncomment for format on save + event = "BufWritePre", -- uncomment for format on save config = function() require "configs.conform" end, }, + { + "ray-x/go.nvim", + lazy = false, + dependencies = { -- optional packages + -- "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require "configs.go" + end, + event = { "CmdlineEnter" }, + ft = { "go", "gomod", "gowork", "gotmpl" }, + build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries + }, -- 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" - -- }, - -- }, - -- }, - -- + { + "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", + "gopls", + "goimports", + "golines", + "gofumpt", + }, + }, + }, -- { -- "nvim-treesitter/nvim-treesitter", -- opts = {