Added nvim config

This commit is contained in:
Steven Polley 2024-02-20 20:05:41 -07:00
parent c856ab9be8
commit d9a86a45dc
11 changed files with 329 additions and 0 deletions

View File

@ -0,0 +1,30 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" },
"base46": { "branch": "v2.0", "commit": "3f2b658cbd6650ddaf2bae3233e143a41ca25b1a" },
"better-escape.nvim": { "branch": "master", "commit": "7e86edafb8c7e73699e0320f225464a298b96d12" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "61cff430c9f15770d0c5e68c1b08067223bd94ab" },
"friendly-snippets": { "branch": "main", "commit": "dbd45e9ba76d535e4cba88afa1b7aa43bb765336" },
"gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" },
"indent-blankline.nvim": { "branch": "master", "commit": "b7aa0aed55887edfaece23f7b46ab22232fc8741" },
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
"nvim-autopairs": { "branch": "master", "commit": "2e8a10c5fc0dcaf8296a5f1a7077efcd37065cc8" },
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" },
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
"nvim-lspconfig": { "branch": "master", "commit": "d1bab4cf4b69e49d6058028fd933d8ef5e74e680" },
"nvim-tree.lua": { "branch": "master", "commit": "d35a8d5ec6358ada4b058431b367b32360737466" },
"nvim-treesitter": { "branch": "master", "commit": "f197a15b0d1e8d555263af20add51450e5aaa1f0" },
"nvim-web-devicons": { "branch": "master", "commit": "14ac5887110b06b89a96881d534230dac3ed134d" },
"nvterm": { "branch": "main", "commit": "3e43be1d0ca60cc5e2dfc2d289b06577e7e57e98" },
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
"telescope.nvim": { "branch": "master", "commit": "b744cf59752aaa01561afb4223006de26f3836fd" },
"ui": { "branch": "v2.0", "commit": "a0d3fd0adc5fd81dc5128ca3b33949196eb1fee8" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

View File

@ -0,0 +1,3 @@
# Example_config
This can be used as an example custom config for NvChad. Do check the https://github.com/NvChad/nvcommunity

View File

@ -0,0 +1,21 @@
---@type ChadrcConfig
local M = {}
-- Path to overriding theme and highlights files
local highlights = require "custom.highlights"
M.ui = {
theme = "gatekeeper",
theme_toggle = { "gatekeeper", "one_light" },
hl_override = highlights.override,
hl_add = highlights.add,
transparency = true,
}
M.plugins = "custom.plugins"
-- check core.mappings for table structure
M.mappings = require "custom.mappings"
return M

View File

@ -0,0 +1,25 @@
--type conform.options
local options = {
lsp_fallback = true,
formatters_by_ft = {
lua = { "stylua" },
javascript = { "prettier" },
css = { "prettier" },
html = { "prettier" },
sh = { "shfmt" },
},
-- adding same formatter for multiple filetypes can look too much work for some
-- instead of the above code you could just use a loop! the config is just a table after all!
-- format_on_save = {
-- -- These options will be passed to conform.format()
-- timeout_ms = 500,
-- lsp_fallback = true,
-- },
}
require("conform").setup(options)

View File

@ -0,0 +1,35 @@
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"
-- if you just want default config for the servers then put them in a table
local servers = { "html", "cssls", "tsserver", "clangd" }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
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,
usePlaceholds = true,
analyses = {
unusedparams = true,
},
},
},
}
--
-- lspconfig.pyright.setup { blabla}
--

View File

@ -0,0 +1,25 @@
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

View File

@ -0,0 +1,68 @@
local M = {}
M.treesitter = {
ensure_installed = {
"vim",
"lua",
"html",
"css",
"javascript",
"typescript",
"tsx",
"c",
"go",
"yaml",
"sql",
"markdown",
"markdown_inline",
},
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",
"prettier",
-- c/cpp stuff
"clangd",
"clang-format",
-- shell stuff
"shfmt",
-- golang stuff
"gopls",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
return M

View File

@ -0,0 +1,19 @@
-- To find any highlight groups: "<cmd> 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

View File

@ -0,0 +1,7 @@
-- local autocmd = vim.api.nvim_create_autocmd
-- Auto resize panes when resizing nvim window
-- autocmd("VimResized", {
-- pattern = "*",
-- command = "tabdo wincmd =",
-- })

View File

@ -0,0 +1,24 @@
---@type MappingsTable
local M = {}
M.general = {
n = {
[";"] = { ":", "enter command mode", opts = { nowait = true } },
-- format with conform
["<leader>fm"] = {
function()
require("conform").format()
end,
"formatting",
}
},
v = {
[">"] = { ">gv", "indent"},
},
}
-- more keybinds!
return M

View File

@ -0,0 +1,72 @@
local overrides = require("custom.configs.overrides")
---@type NvPluginSpec[]
local plugins = {
-- Override plugin definition options
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end, -- Override to setup mason-lspconfig
},
{
"jose-elias-alvarez/null-ls.nvim",
ft = "go",
opts = function()
return require "custom.configs.null-ls"
end,
},
-- override plugin configs
{
"williamboman/mason.nvim",
opts = overrides.mason
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Install a plugin
{
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("better_escape").setup()
end,
},
{
"stevearc/conform.nvim",
-- for users those who want auto-save conform + lazyloading!
-- event = "BufWritePre"
config = function()
require "custom.configs.conform"
end,
},
-- To make a plugin not be loaded
-- {
-- "NvChad/nvim-colorizer.lua",
-- enabled = false
-- },
-- All NvChad plugins are lazy-loaded by default
-- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false`
-- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example
-- {
-- "mg979/vim-visual-multi",
-- lazy = false,
-- }
}
return plugins