commit d4d1f1ece2183e348f08fdf64f94c15c15544ad6 Author: Neil Hanlon Date: Mon Mar 20 18:13:41 2023 -0400 Initial commit diff --git a/chadrc.lua b/chadrc.lua new file mode 100644 index 0000000..827e10f --- /dev/null +++ b/chadrc.lua @@ -0,0 +1,23 @@ +---@type ChadrcConfig +local M = {} + +-- Path to overriding theme and highlights files +local highlights = require "custom.highlights" + +M.ui = { + theme = "onedark", + theme_toggle = { "onedark", "one_light" }, + + hl_override = highlights.override, + hl_add = highlights.add, + nvdash = { + load_on_startup = true + } +} + +M.plugins = "custom.plugins" + +-- check core.mappings for table structure +M.mappings = require "custom.mappings" + +return M diff --git a/configs/lspconfig.lua b/configs/lspconfig.lua new file mode 100644 index 0000000..63454ad --- /dev/null +++ b/configs/lspconfig.lua @@ -0,0 +1,28 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require "lspconfig" + +-- if you just want default config for the servers then put them in a table +-- local servers = { "html", "cssls", "pyright", "ansiblels", "bashls", "yamlls", "sqlls" } + +-- for _, lsp in ipairs(servers) do +-- lspconfig[lsp].setup { +-- on_attach = on_attach, +-- capabilities = capabilities, +-- } +-- end + +lspconfig.gopls.setup { + -- on_attach = lspconfig.on_attach, + -- capabilities = lspconfig.capabilities, + cmd = { "gopls", "serve" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, +} diff --git a/configs/null-ls.lua b/configs/null-ls.lua new file mode 100644 index 0000000..de7a6f8 --- /dev/null +++ b/configs/null-ls.lua @@ -0,0 +1,57 @@ +local present, null_ls = pcall(require, "null-ls") + +if not present then + return +end + +local b = null_ls.builtins + +local sources = { + + -- webdev stuff + b.formatting.deno_fmt, + b.formatting.prettier, + b.code_actions.eslint_d, + + -- python stuff + b.diagnostics.pylint, + b.formatting.reorder_python_imports, + b.formatting.black, + + -- Lua + b.formatting.stylua, + + -- Shell + b.formatting.shfmt, + b.diagnostics.shellcheck.with { diagnostics_format = "#{m} [#{c}]" }, + + -- psql + b.formatting.sqlfluff.with { + extra_args = { "--dialect", "postgres" }, + }, + b.diagnostics.sqlfluff.with { + extra_args = { "--dialect", "postgres" }, + }, + + -- Generic + -- b.formatting.remark, + -- b.diagnostics.semgrep, + b.code_actions.refactoring, + b.diagnostics.yamllint, + + -- golang + b.diagnostics.golangci_lint, + b.formatting.gofmt, + b.formatting.goimports, + b.formatting.goimports_reviser, + b.formatting.protolint, + + -- bazel + b.diagnostics.buildifier, + b.formatting.buildifier, +} + +null_ls.setup { + debug = true, + sources = sources, +} diff --git a/configs/overrides.lua b/configs/overrides.lua new file mode 100644 index 0000000..e29d5e1 --- /dev/null +++ b/configs/overrides.lua @@ -0,0 +1,62 @@ +local M = {} + +M.treesitter = { + ensure_installed = { + "bash", + "c", + "css", + "go", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "toml", + "vim", + "yaml", + }, + indent = { + enable = true, + disable = { + "python" + }, + }, +} + +M.mason = { + ensure_installed = { + -- lua stuff + "lua-language-server", + "stylua", + + -- web dev stuff + "css-lsp", + "html-lsp", + "typescript-language-server", + "deno", + + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + view = { + width = 25, + adaptive_size = true + }, + renderer = { + highlight_git = true, + symlink_destination = false, + icons = { + show = { + git = true, + }, + }, + }, +} + +return M diff --git a/highlights.lua b/highlights.lua new file mode 100644 index 0000000..547c637 --- /dev/null +++ b/highlights.lua @@ -0,0 +1,19 @@ +-- To find any highlight groups: " Telescope highlights" +-- Each highlight group can take a table with variables fg, bg, bold, italic, etc +-- base30 variable names can also be used as colors + +local M = {} + +---@type Base46HLGroupsList +M.override = { + Comment = { + italic = true, + }, +} + +---@type HLTable +M.add = { + -- NvimTreeOpenedFolderName = { fg = "green", bold = true }, +} + +return M diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e6ac28f --- /dev/null +++ b/init.lua @@ -0,0 +1,29 @@ +-- local autocmd = vim.api.nvim_create_autocmd + +-- Auto resize panes when resizing nvim window +-- autocmd("VimResized", { +-- pattern = "*", +-- command = "tabdo wincmd =", +-- }) + +vim.api.nvim_create_augroup('numbertoggle', { clear = true }) +vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'InsertLeave', 'WinEnter' }, { + group = 'numbertoggle', + pattern = '*', + command = 'if &nu && mode() != "i" | set rnu | endif' +}) +vim.api.nvim_create_autocmd({ 'BufLeave', 'FocusLost', 'InsertEnter', 'WinLeave' }, { + group = 'numbertoggle', + pattern = '*', + command = 'if &nu | set nornu | endif' +}) + +vim.api.nvim_create_autocmd({'BufWritePre'}, { + pattern = "", + command = 'lua vim.lsp.buf.format()' +}) + +vim.api.nvim_create_autocmd({'BufWritePre'}, { + pattern = "*.go", + command = ":silent! lua require('go.format').gofmt()" +}) diff --git a/mappings.lua b/mappings.lua new file mode 100644 index 0000000..ced2860 --- /dev/null +++ b/mappings.lua @@ -0,0 +1,10 @@ +---@type MappingsTable +local M = {} + +M.general = { + n = { + [";"] = { ":", "enter command mode", opts = { nowait = true } }, + }, +} + +return M diff --git a/plugins.lua b/plugins.lua new file mode 100644 index 0000000..1bb4df5 --- /dev/null +++ b/plugins.lua @@ -0,0 +1,51 @@ +local overrides = require("custom.configs.overrides") + +---@type NvPluginSpec[] +local plugins = { + + { + "neovim/nvim-lspconfig", + dependencies = { + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require "custom.configs.null-ls" + end, + }, + }, + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, -- Override to setup mason-lspconfig + }, + { + "williamboman/mason.nvim", + opts = overrides.mason + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + { + "nvim-tree/nvim-tree.lua", + opts = overrides.nvimtree, + }, + { + "folke/which-key.nvim", + enabled = true, + }, + { + "intrntbrn/awesomewm-vim-tmux-navigator" + }, + { + "hashivim/vim-terraform", + config = function() + vim.g.terraform_align = 1 + vim.g.terraform_fmt_on_save = 1 + vim.g.hcl_align = 1 + end, + }, +} + +return plugins