Add go.nvim + wsl optimizations

main
Gabe Farrell 2 years ago
parent 63046022c9
commit 8e6e367f7a

@ -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 -- https://github.com/NvChad/NvChad/blob/v2.5/lua/nvconfig.lua
---@type ChadrcConfig ---@type ChadrcConfig
local M = {} local M = {}
M.ui = { M.ui = {
theme = "onedark", theme = "yoru",
-- hl_override = { hl_override = {
-- Comment = { italic = true }, Comment = { italic = true },
-- ["@comment"] = { italic = true }, ["@comment"] = { italic = true },
-- }, },
} }
return M return M

@ -1,15 +1,15 @@
local options = { local options = {
formatters_by_ft = { formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },
-- css = { "prettier" }, css = { "prettier" },
-- html = { "prettier" }, html = { "prettier" },
}, },
-- format_on_save = { format_on_save = {
-- -- These options will be passed to conform.format() -- These options will be passed to conform.format()
-- timeout_ms = 500, timeout_ms = 500,
-- lsp_fallback = true, lsp_fallback = true,
-- }, },
} }
require("conform").setup(options) require("conform").setup(options)

@ -0,0 +1 @@
require("go").setup()

@ -1,10 +1,10 @@
-- EXAMPLE -- EXAMPLE
local on_attach = require("nvchad.configs.lspconfig").on_attach local on_attach = require("nvchad.configs.lspconfig").on_attach
local on_init = require("nvchad.configs.lspconfig").on_init local on_init = require("nvchad.configs.lspconfig").on_init
local capabilities = require("nvchad.configs.lspconfig").capabilities local capabilities = require("nvchad.configs.lspconfig").capabilities
local lspconfig = require "lspconfig" local lspconfig = require "lspconfig"
local servers = { "html", "cssls" } local servers = { "html", "cssls", "gopls" }
-- lsps with default config -- lsps with default config
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do

@ -1,12 +1,12 @@
require "nvchad.options" require "nvchad.options"
-- add yours here! -- add yours here!
vim.opt.mouse='' vim.opt.mouse = ""
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
once = true, once = true,
callback = function() 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 = { vim.g.clipboard = {
copy = { copy = {
["+"] = "win32yank.exe -i --crlf", ["+"] = "win32yank.exe -i --crlf",
@ -17,8 +17,8 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
["*"] = "win32yank.exe -o --lf", ["*"] = "win32yank.exe -o --lf",
}, },
} }
elseif vim.fn.has("unix") == 1 then elseif vim.fn.has "unix" == 1 then
if vim.fn.executable("xclip") == 1 then if vim.fn.executable "xclip" == 1 then
vim.g.clipboard = { vim.g.clipboard = {
copy = { copy = {
["+"] = "xclip -selection clipboard", ["+"] = "xclip -selection clipboard",
@ -29,7 +29,7 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
["*"] = "xclip -selection clipboard -o", ["*"] = "xclip -selection clipboard -o",
}, },
} }
elseif vim.fn.executable("xsel") == 1 then elseif vim.fn.executable "xsel" == 1 then
vim.g.clipboard = { vim.g.clipboard = {
copy = { copy = {
["+"] = "xsel --clipboard --input", ["+"] = "xsel --clipboard --input",
@ -47,5 +47,16 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
end, end,
desc = "Lazy load clipboard", 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!

@ -1,31 +1,52 @@
return { return {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
-- event = 'BufWritePre', -- uncomment for format on save event = "BufWritePre", -- uncomment for format on save
config = function() config = function()
require "configs.conform" require "configs.conform"
end, 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! -- These are some examples, uncomment them if you want to see them work!
-- { {
-- "neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
-- config = function() config = function()
-- require("nvchad.configs.lspconfig").defaults() require("nvchad.configs.lspconfig").defaults()
-- require "configs.lspconfig" require "configs.lspconfig"
-- end, end,
-- }, },
--
-- { {
-- "williamboman/mason.nvim", "williamboman/mason.nvim",
-- opts = { opts = {
-- ensure_installed = { ensure_installed = {
-- "lua-language-server", "stylua", "lua-language-server",
-- "html-lsp", "css-lsp" , "prettier" "stylua",
-- }, "html-lsp",
-- }, "css-lsp",
-- }, "prettier",
-- "gopls",
"goimports",
"golines",
"gofumpt",
},
},
},
-- { -- {
-- "nvim-treesitter/nvim-treesitter", -- "nvim-treesitter/nvim-treesitter",
-- opts = { -- opts = {

Loading…
Cancel
Save