migrate to nvchad 2.5

This commit is contained in:
Mira Kristipati 2024-05-08 22:50:12 -04:00
parent aad624221a
commit 95ddb947b4
10 changed files with 762 additions and 56 deletions

View file

@ -35,5 +35,74 @@ dofile(vim.g.base46_cache .. "statusline")
require "nvchad.autocmds"
vim.schedule(function()
require "mappings"
local mappings = require "mappings"
mappings.General()
end)
local autocmd = vim.api.nvim_create_autocmd
-- Auto resize panes when resizing nvim window
autocmd("VimResized", {
pattern = "*",
command = "tabdo wincmd =",
})
-- if windows or WSL
if vim.loop.os_uname() == "win32" then
vim.g.clipboard = {
name = "WslClipboard",
copy = {
["+"] = "clip.exe",
["*"] = "clip.exe",
},
paste = {
["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
},
cache_enabled = 0,
}
-- if nvim supports osc52
elseif pcall(require, "vim.ui.clipboard.osc52") then
vim.g.clipboard = {
name = "OSC 52",
copy = {
["+"] = require("vim.ui.clipboard.osc52").copy,
["*"] = require("vim.ui.clipboard.osc52").copy,
},
paste = {
["+"] = require("vim.ui.clipboard.osc52").paste,
["*"] = require("vim.ui.clipboard.osc52").paste,
},
}
-- use osc52 plugin
elseif pcall(require, "osc52") then
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return { vim.fn.split(vim.fn.getreg "", "\n"), vim.fn.getregtype "" }
end
vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}
end
vim.opt.relativenumber = true
vim.opt.cursorline = true
if vim.loop.os_uname() == "win32" then
vim.opt.shell = vim.fn.executable "pwsh" == 1 and "pwsh" or "powershell"
vim.opt.shellcmdflag =
"-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
vim.opt.shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait"
vim.opt.shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode"
vim.opt.shellquote = ""
vim.opt.shellxquote = ""
else
vim.opt.shell = vim.fn.executable "zsh" == 1 and "zsh" or "bash"
end
vim.g.copilot_assume_mapped = true
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.foldenable = false

View file

@ -1,16 +1,25 @@
-- 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 = {}
-- Path to overriding theme and highlights files
local highlights = require "highlights"
M.ui = {
theme = "onedark",
theme = "lunar_witch",
-- theme_toggle = { "onedark", "one_light" },
-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
hl_override = highlights.override,
hl_add = highlights.add,
statusline = {
overriden_modules = function (modules)
modules[10] = vim.o.columns > 140 and "%#StText# [%l,%c]" or ""
end
}
}
-- M.plugins = "plugins"
-- check core.mappings for table structure
-- M.mappings = require "mappings"
return M

View file

@ -1,23 +1,57 @@
-- EXAMPLE
local lspconfig = require "lspconfig"
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" }
-- if you just want default config for the servers then put them in a table
local servers = {
"html",
"cssls",
"tsserver",
"clangd",
"gopls",
"astro",
"docker_compose_language_service",
"ast_grep",
-- "basedpyright",
"bashls",
"css_variables",
}
-- lsps with default config
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
}
end
-- typescript
lspconfig.tsserver.setup {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
lspconfig.lua_ls.setup {
on_init = function(client)
local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
},
},
})
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end,
}
require("copilot").setup()

56
lua/configs/null-ls.lua Normal file
View file

@ -0,0 +1,56 @@
local null_ls = require "null-ls"
local virtual = os.getenv "VIRTUAL_ENV" or os.getenv "CONDA_PREFIX" or "/usr" -- TODO: windows
local opts = {
debug = true,
sources = {
null_ls.builtins.code_actions.refactoring,
null_ls.builtins.diagnostics.mypy.with {
-- extra_args = { "--python-executable", virtual .. "/bin/python3" },
},
-- null_ls.builtins.diagnostics.flake8.with {
-- extra_args = { "--select", "E,W,F", "--ignore", "E501,E402,E722,W503", "--max-line-length", "150" },
-- },
-- null_ls.builtins.formatting.autoflake,
-- null_ls.builtins.formatting.autopep8.with {
-- extra_args = { "--select", "E,W,F", "--ignore", "E501,E402,E722,W503", "--max-line-length", "150" },
-- },
-- Lua
null_ls.builtins.formatting.stylua,
-- CSS
null_ls.builtins.formatting.prettier,
-- Go
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.formatting.goimports,
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl,
-- null_ls.builtins.diagnostics.revive,
null_ls.builtins.diagnostics.golangci_lint,
-- Docker
null_ls.builtins.diagnostics.hadolint,
--shell,
null_ls.builtins.formatting.shellharden,
-- web
require "none-ls.code_actions.eslint",
require "none-ls.diagnostics.eslint",
require "none-ls.formatting.eslint",
null_ls.builtins.formatting.stylelint,
},
-- autoformat on save
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

66
lua/configs/overrides.lua Normal file
View file

@ -0,0 +1,66 @@
local M = {}
M.treesitter = {
ensure_installed = {
"vim",
"lua",
"html",
"css",
"javascript",
"typescript",
"tsx",
"c",
"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",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
M.copilot = {
config = function(_, opts)
require("core.utils").load_mappings "copilot"
end,
suggestion = {
auto_trigger = true,
},
}
return M

View file

@ -0,0 +1,11 @@
local on_attach = require("nvchad.configs.lspconfig").on_attach
local capabilities = require("nvchad.configs.lspconfig").capabilities
local options = {
server = {
on_attach = on_attach,
capabilities = capabilities,
}
}
return options

34
lua/highlights.lua Normal file
View file

@ -0,0 +1,34 @@
-- 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,
},
St_NormalMode = {
fg = "white",
bold = false,
},
St_InsertMode = {
fg = "white",
bold = false,
},
St_LspStatus = {
fg = "blue",
},
}
---@type HLTable
M.add = {
NvimTreeOpenedFolderName = { fg = "green", bold = true },
NvimTreeImageFile = { fg = "dark_purple" },
DevIconTxt = { fg = "green" },
NvimTreeSpecialFile = {
fg = "yellow",
},
}
return M

View file

@ -1,10 +1,116 @@
require "nvchad.mappings"
-- add yours here
local map = vim.keymap.set
map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>")
-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")
local M = {}
M.General = function()
map("n", ";", ":", { desc = "general enter command mode", nowait = true })
map("v", ">", ">gv", { desc = "general indent" })
map("n", "<C-Left>", "<C-w>h", { desc = "general Window left" })
map("n", "<C-Right>", "<C-w>l", { desc = "general Window right" })
map("n", "<C-Down>", "<C-w>j", { desc = "general Window down" })
map("n", "<C-Up>", "<C-w>k", { desc = "general Window up" })
end
M.Dap = function()
map("n", "<leader>db", "<cmd> DapToggleBreakpoint <CR>", { desc = "dap Toggle Breakpoint" })
map("n", "<leader>dus", function()
local widgets = require "dap.ui.widgets"
local sidebar = widgets.sidebar(widgets.scopes)
sidebar.open()
end, { desc = "dap Open debugging sidebar" })
map("n", "<F5>", function()
require("dap").continue()
end, { desc = "dap Debug Program" })
map("n", "<F10>", function()
require("dap").step_over()
end, { desc = "dap Step Over" })
map("n", "<F11>", function()
require("dap").step_into()
end, { desc = "dap Step Into" })
map("n", "<F12>", function()
require("dap").step_out()
end, { desc = "dap Step Out" })
map("n", "<Leader>lp", function()
require("dap").set_breakpoint(nil, nil, vim.fn.input "Log point message: ")
end, { desc = "dap Set Breakpoint with Mesage?" })
map("n", "<Leader>dr", function()
require("dap").repl.open()
end, { desc = "dap Open REPL" })
map("n", "<Leader>dl", function()
require("dap").run_last()
end, { desc = "dap Run Last" })
map("n", "<Leader>dp", function()
require("dap.ui.widgets").preview()
end, { desc = "dap Preview UI" })
map("n", "<Leader>dh", function()
require("dap.ui.widgets").hover()
end, { desc = "dap Hover UI" })
map("n", "<Leader>do", function()
require("dapui").toggle()
end, { desc = "dap Toggle Debug UI" })
map("n", "<Leader>df", function()
local widgets = require "dap.ui.widgets"
widgets.centered_float(widgets.frames)
end, { desc = "dap Open Frames" })
map("n", "<Leader>ds", function()
local widgets = require "dap.ui.widgets"
widgets.centered_float(widgets.scopes)
end, { desc = "dap Open Scopes" })
end
M.Dap_python = function()
map("n", "<leader>dpr", function()
require("dap-python").test_method()
end, { desc = "dap_python Test Method" })
end
M.Dap_go = function()
map("n", "<leader>dpr", function()
require("dap-go").debug_test()
end, { desc = "dap_go Test Method" })
end
M.Crates = function()
map("n", "<leader>rcu", function()
require("crates").upgrade_all_crates()
end, { desc = "crates update crates" })
end
M.LazyGit = function()
map("n", "<leader>gg", function()
vim.cmd ":LazyGit"
end, { desc = "lazygit open lazygit" })
end
M.Hop = function()
map("n", "t", function()
require("hop").hint_words { multi_windows = true }
end, { desc = "hop Hop across windows", remap = true })
map("n", "T", function()
require("hop").hint_char2 { multi_windows = true }
end, {
desc = "hop Hop to chars across windows",
remap = true,
})
end
M.Copilot = function()
map("i", "<M-l>", function()
require("copilot.suggestion").accept()
end, { desc = "copilot Accept Suggestion", "opts = { remap = true }" })
map("i", "<M-)>", function()
require("copilot.suggestion").next()
end, { desc = "copilot Next Suggestion", "opts = { remap = true }" })
map("i", "<M-map(>", function()
require("copilot.suggestion").prev()
end, { desc = "copilot rev Suggestion", "opts = { remap = true }" })
map("i", "<C-)>", function()
require("copilot.suggestion").dismiss()
end, { desc = "copilot Dismiss Suggestion", "opts = { remap = true }" })
end
M.Markdown = function()
map("n", "<leader>cb", function()
require("markdown-togglecheck").toggle()
end, { desc = "markdown Toggle Checkmark" })
end
M.Obsidian = function()
map("n", "gf", function()
return require("obsidian").util.gf_passthrough()
end, { desc = "obsidian Follow Link", "opts = { noremap = false, expr = true, buffer = true }" })
map("n", "<leader>cb", function()
return require("obsidian").util.toggle_checkbox()
end, { desc = "obsidian Toggle Checkmark", "opts = { buffer = trueue, remap = true }" })
end
return M

View file

@ -1,38 +1,292 @@
local overrides = require "configs.overrides"
local mappings = require "mappings"
---@type NvPluginSpec[]
return {
---------------------
-- General Plugins --
---------------------
-- LSP Stuff
{
"stevearc/conform.nvim",
-- event = 'BufWritePre', -- uncomment for format on save
"williamboman/mason.nvim",
-- opts = overrides.mason
opts = {
ensure_installed = {
-- rust stuff
"rust-analyzer",
-- lua stuff
"lua-language-server",
"stylua",
-- web dev stuff
"css-lsp",
"html-lsp",
"typescript-language-server",
-- "deno",
"prettier",
-- c/cpp slike he has tuff
"clangd",
"clang-format",
-- python stuff
"pyright",
"mypy",
"autoflake",
"debugpy",
-- "ruff",
"shellharden",
"gopls",
},
},
},
{ "ThePrimeagen/refactoring.nvim" },
{
"nvimtools/none-ls.nvim",
lazy = false,
dependencies = "nvimtools/none-ls-extras.nvim",
opts = function()
return require "configs.null-ls"
end,
},
{
"neovim/nvim-lspconfig",
config = function()
require "configs.conform"
require "nvchad.configs.lspconfig"
require "configs.lspconfig"
end, -- Override to setup mason-lspconfig
lazy = false,
},
-- Debugger
{
"mfussenegger/nvim-dap",
config = function(_, opts)
mappings.Dap()
end,
},
{
"rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
config = function()
local dap = require "dap"
local dapui = require "dapui"
dapui.setup()
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
end,
},
-- These are some examples, uncomment them if you want to see them work!
-- Delimiters
{ "Raimondi/delimitMate", lazy = false },
-- lazygit
{
"kdheepak/lazygit.nvim",
config = function()
mappings.LazyGit()
end,
lazy = false,
},
-- fzf
{ "junegunn/fzf.vim", lazy = false },
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim", "junegunn/fzf.vim" },
},
-- Syntax Highlighting
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
dependencies = {
-- NOTE: additional parser
{ "nushell/tree-sitter-nu" },
},
},
-- File manager
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Syntax Highlighting
{
"nvim-treesitter/nvim-treesitter",
-- TODO:
opts = overrides.treesitter,
},
-- File manager
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Install a plugin
{
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("better_escape").setup()
end,
},
-- TODO: remove this on nvim 0.10
{
"ojroques/nvim-osc52",
config = function()
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return { vim.fn.split(vim.fn.getreg "", "\n"), vim.fn.getregtype "" }
end
vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}
-- Now the '+' register will copy to system clipboard using OSC52
-- vim.keymap.set('n', '<leader>c', '"+y')
-- vim.keymap.set('n', '<leader>cc', '"+yy')
end,
},
{ "zbirenbaum/copilot.lua", event = "InsertEnter", opts = overrides.copilot, lazy = false },
-- Nyoom around files
{
"smoka7/hop.nvim",
lazy = false,
config = function()
local hop = require "hop"
hop.setup()
print(mappings.Hop())
end,
},
------------
-- Python --
------------
{
"mfussenegger/nvim-dap-python",
ft = "python",
dependencies = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
},
config = function(_, opts)
local path = nil
local is_windows = vim.fn.has "win64" == 1 or vim.fn.has "win32" == 1 or vim.fn.has "win16" == 1
if is_windows then
local cmd = io.popen("where.exe python", "r")
path = cmd:read "*line"
cmd:close()
else
local cmd = io.popen("which python", "r")
path = cmd:read "*line"
cmd:close()
end
require("dap-python").setup(path)
mappings.Dap_python()
end,
},
----------
-- Rust --
----------
{
"rust-lang/rust.vim",
ft = "rust",
init = function()
vim.g.rustfmt_autosave = 1
end,
},
{
"simrat39/rust-tools.nvim",
ft = "rust",
dependencies = "neovim/nvim-lspconfig",
opts = function()
return require "configs.rust-tools"
end,
config = function(_, opts)
require("rust-tools").setup(opts)
end,
},
{
"saecki/crates.nvim",
ft = { "rust", "toml" },
config = function(_, opts)
local crates = require "crates"
crates.setup(opts)
crates.show()
end,
},
-----------
-- swkhd --
-----------
{ "waycrate/swhkd-vim", ft = { "swhkdrc", "swhkd" } },
--------------
-- Obsidian --
--------------
-- {
-- "neovim/nvim-lspconfig",
-- config = function()
-- require("nvchad.configs.lspconfig").defaults()
-- require "configs.lspconfig"
-- end,
-- "epwalsh/obsidian.nvim",
-- ft = "markdown",
-- lazy = false,
-- dependencies = {
-- "nvim-lua/plenary.nvim",
-- "nvim-telescope/telescope.nvim",
-- "nvim-treesitter/nvim-treesitter",
-- },
-- opts = {
-- -- workspaces = {}
-- config = function(_, opts)
-- end,
-- },
-- },
--
--------------
-- Markdown --
--------------
{
"nfrid/markdown-togglecheck",
dependencies = { "nfrid/treesitter-utils" },
ft = { "markdown" },
config = function(_, opts)
-- require("markdown-togglecheck").setup()
mappings.Markdown()
end,
},
------------
-- Golang --
------------
{
"leoluz/nvim-dap-go",
dependencies = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
},
ft = "go",
config = function(_, opts)
require("dap-go").setup()
mappings.Dap_go()
end,
},
-- 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
-- {
-- "williamboman/mason.nvim",
-- opts = {
-- ensure_installed = {
-- "lua-language-server", "stylua",
-- "html-lsp", "css-lsp" , "prettier"
-- },
-- },
-- },
--
-- {
-- "nvim-treesitter/nvim-treesitter",
-- opts = {
-- ensure_installed = {
-- "vim", "lua", "vimdoc",
-- "html", "css"
-- },
-- },
-- },
-- "mg979/vim-visual-multi",
-- lazy = false,
-- }
}

View file

@ -0,0 +1,67 @@
local M = {}
M.base_30 = {
black = "#010206",-- theme bg
darker_black = "#000000",
black2 = "#2A2644", -- base02
one_bg = "#1E1B30", -- base01
one_bg2 = "#2A2644", -- base02
one_bg3 = "#51545A", -- base03
light_grey = "#BFBFC0", -- base05
grey_fg = "#51545A", -- base04, used for comments
grey = "#5078A4", -- accent
grey_fg2 = "#0B5393", -- light accent, used for line numbers
line = "#2A2644", -- base02
baby_pink = "#F385A6", -- pink
nord_blue = "#0B5393", -- accent
orange = "#F4B766",
statusline_bg = "#1E1B30", -- base01
lightbg = "#2a2644", -- base02
lightbg2 = "#2a2644", -- base02
folder_bg = "#445F9B", -- ansi-blue
pmenu_bg = "#445F9B", -- ansi-blue
red = "#A04558",
green = "#6FA47E",
yellow = "#E0CA00",
dark_purple = "#9B4271", --ansi-magenta
teal = "#2A97B1", -- ansi-cyan
pink = "#F5A9B8", --ansi-bright-red
vibrant_green = "#98DB95", --ansi-bright-green
sun = "#ffe70a", -- ansi-bright-yellow
blue = "#445F9B", --ansi-bright-blue
purple = "#ee5e95", --ansi-bright-magenta
cyan = "#5BCEFA", --ansi-bright-cyan
white = "#ebf6ff", -- actually fg
}
M.base_16 = {
base00 = "#010206",-- Default bg
base01 = "#1E1B30",-- Lighter bg (status bar, line number, folding mks)
base02 = "#2A2644",-- Selection bg,
base03 = "#51545A",-- Comments, invisibles, line hl, ansi-bright-black
base04 = "#808082",-- Dark fg (status bars), ansi-white
base05 = "#BFBFC0",-- Default fg (caret, delimiters, Operators), ansi-bright-white
base06 = "#EBF6FF",-- Light fg (not often used), fg
base07 = "#F0F2FF",-- Light bg (not often used)
base08 = "#F5A9B8",-- Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted, ansi-bright-red
base09 = "#F4B766",-- Integers, Boolean, Constants, XML Attributes, Markup Link Url, orange
base0A = "#E0CA00",-- Classes, Markup Bold, Search Text Background, ansi-yellow
base0B = "#98DB95",-- Strings, Inherited Class, Markup Code, Diff Inserted, ansi-green
base0C = "#2A97B1",-- Support, regex, escape chars, ansi-cyan
base0D = "#5BCEFA",-- Function, methods, headings, ansi-bright-cyan
base0E = "#EE5E95",-- Keywords, ansi-bright-magenta
base0F = "#A34A78",-- Deprecated, open/close embedded tags, ansi-magenta
}
M.type = "dark"
return M