mirror of
https://github.com/Derisis13/dotfiles.git
synced 2025-12-06 19:32:50 +01:00
feat: neovim config based on NvChad
This commit is contained in:
6
nvim/.stylua.toml
Normal file
6
nvim/.stylua.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
column_width = 120
|
||||||
|
line_endings = "Unix"
|
||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
quote_style = "AutoPreferDouble"
|
||||||
|
call_parentheses = "None"
|
||||||
40
nvim/init.lua
Normal file
40
nvim/init.lua
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
-- bootstrap lazy and all plugins
|
||||||
|
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
|
||||||
|
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
local repo = "https://github.com/folke/lazy.nvim.git"
|
||||||
|
vim.fn.system { "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath }
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
local lazy_config = require "configs.lazy"
|
||||||
|
|
||||||
|
-- load plugins
|
||||||
|
require("lazy").setup({
|
||||||
|
{
|
||||||
|
"NvChad/NvChad",
|
||||||
|
lazy = false,
|
||||||
|
branch = "v2.5",
|
||||||
|
import = "nvchad.plugins",
|
||||||
|
config = function()
|
||||||
|
require "options"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{ import = "plugins" },
|
||||||
|
}, lazy_config)
|
||||||
|
|
||||||
|
-- load theme
|
||||||
|
dofile(vim.g.base46_cache .. "defaults")
|
||||||
|
dofile(vim.g.base46_cache .. "statusline")
|
||||||
|
|
||||||
|
require "nvchad.autocmds"
|
||||||
|
|
||||||
|
vim.schedule(function()
|
||||||
|
require "mappings"
|
||||||
|
end)
|
||||||
|
require "myinit"
|
||||||
93
nvim/lua/chadrc.lua
Executable file
93
nvim/lua/chadrc.lua
Executable file
@@ -0,0 +1,93 @@
|
|||||||
|
local options = {
|
||||||
|
|
||||||
|
base46 = {
|
||||||
|
theme = "catppuccin", -- default theme
|
||||||
|
hl_add = {},
|
||||||
|
hl_override = {},
|
||||||
|
integrations = {},
|
||||||
|
changed_themes = {
|
||||||
|
all = {
|
||||||
|
base_16 = { base00 = "none" }, -- make only the main window background transparent
|
||||||
|
},
|
||||||
|
},
|
||||||
|
transparency = true,
|
||||||
|
theme_toggle = { "catppuccin", "one_light" },
|
||||||
|
},
|
||||||
|
|
||||||
|
ui = {
|
||||||
|
cmp = {
|
||||||
|
icons = true,
|
||||||
|
lspkind_text = true,
|
||||||
|
style = "default", -- default/flat_light/flat_dark/atom/atom_colored
|
||||||
|
},
|
||||||
|
|
||||||
|
telescope = { style = "bordered" }, -- borderless / bordered
|
||||||
|
|
||||||
|
statusline = {
|
||||||
|
theme = "minimal", -- default/vscode/vscode_colored/minimal
|
||||||
|
-- default/round/block/arrow separators work only for default statusline theme
|
||||||
|
-- round and block will work for minimal theme only
|
||||||
|
separator_style = "round",
|
||||||
|
order = nil,
|
||||||
|
modules = nil,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- lazyload it when there are 1+ buffers
|
||||||
|
tabufline = {
|
||||||
|
enabled = true,
|
||||||
|
lazyload = true,
|
||||||
|
order = { "treeOffset", "buffers", "tabs", "btns" },
|
||||||
|
modules = nil,
|
||||||
|
},
|
||||||
|
|
||||||
|
nvdash = {
|
||||||
|
load_on_startup = false,
|
||||||
|
|
||||||
|
header = {
|
||||||
|
" ▄ ▄ ",
|
||||||
|
" ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ ",
|
||||||
|
" █ ▄ █▄█ ▄▄▄ █ █▄█ █ █ ",
|
||||||
|
" ▄▄ █▄█▄▄▄█ █▄█▄█▄▄█▄▄█ █ ",
|
||||||
|
" ▄ █▄▄█ ▄ ▄▄ ▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ",
|
||||||
|
" █▄▄▄▄ ▄▄▄ █ ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ █ ▄",
|
||||||
|
"▄ █ █▄█ █▄█ █ █ █▄█ █ █▄█ ▄▄▄ █ █",
|
||||||
|
"█▄█ ▄ █▄▄█▄▄█ █ ▄▄█ █ ▄ █ █▄█▄█ █",
|
||||||
|
" █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █▄█▄▄▄█ ",
|
||||||
|
},
|
||||||
|
|
||||||
|
buttons = {
|
||||||
|
{ " Find File", "Spc f f", "Telescope find_files" },
|
||||||
|
{ " Recent Files", "Spc f o", "Telescope oldfiles" },
|
||||||
|
{ " Find Word", "Spc f w", "Telescope live_grep" },
|
||||||
|
{ " Bookmarks", "Spc m a", "Telescope marks" },
|
||||||
|
{ " Themes", "Spc t h", "Telescope themes" },
|
||||||
|
{ " Mappings", "Spc c h", "NvCheatsheet" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
term = {
|
||||||
|
winopts = { number = false, relativenumber = false },
|
||||||
|
sizes = { sp = 0.3, vsp = 0.2, ["bo sp"] = 0.3, ["bo vsp"] = 0.2 },
|
||||||
|
float = {
|
||||||
|
relative = "editor",
|
||||||
|
row = 0.3,
|
||||||
|
col = 0.25,
|
||||||
|
width = 0.5,
|
||||||
|
height = 0.4,
|
||||||
|
border = "single",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
lsp = { signature = true },
|
||||||
|
|
||||||
|
cheatsheet = {
|
||||||
|
theme = "grid", -- simple/grid
|
||||||
|
excluded_groups = { "terminal (t)", "autopairs", "Nvim", "Opens" }, -- can add group name or with mode
|
||||||
|
},
|
||||||
|
|
||||||
|
mason = { cmd = true, pkgs = {} },
|
||||||
|
}
|
||||||
|
|
||||||
|
local status, chadrc = pcall(require, "chadrc")
|
||||||
|
return vim.tbl_deep_extend("force", options, status and chadrc or {})
|
||||||
30
nvim/lua/configs/conform.lua
Executable file
30
nvim/lua/configs/conform.lua
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
local options = {
|
||||||
|
lsp_fallback = true,
|
||||||
|
|
||||||
|
formatters_by_ft = {
|
||||||
|
lua = { "stylua" },
|
||||||
|
|
||||||
|
css = { "prettier" },
|
||||||
|
html = { "prettier" },
|
||||||
|
|
||||||
|
sh = { "shfmt" },
|
||||||
|
|
||||||
|
python = { "autopep8" },
|
||||||
|
|
||||||
|
latex = { "bibtex-tidy" },
|
||||||
|
|
||||||
|
c = { "clang_format" },
|
||||||
|
cpp = { "clang_format" },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- 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)
|
||||||
47
nvim/lua/configs/lazy.lua
Normal file
47
nvim/lua/configs/lazy.lua
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
return {
|
||||||
|
defaults = { lazy = true },
|
||||||
|
install = { colorscheme = { "nvchad" } },
|
||||||
|
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
ft = "",
|
||||||
|
lazy = " ",
|
||||||
|
loaded = "",
|
||||||
|
not_loaded = "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
performance = {
|
||||||
|
rtp = {
|
||||||
|
disabled_plugins = {
|
||||||
|
"2html_plugin",
|
||||||
|
"tohtml",
|
||||||
|
"getscript",
|
||||||
|
"getscriptPlugin",
|
||||||
|
"gzip",
|
||||||
|
"logipat",
|
||||||
|
"netrw",
|
||||||
|
"netrwPlugin",
|
||||||
|
"netrwSettings",
|
||||||
|
"netrwFileHandlers",
|
||||||
|
"matchit",
|
||||||
|
"tar",
|
||||||
|
"tarPlugin",
|
||||||
|
"rrhelper",
|
||||||
|
"spellfile_plugin",
|
||||||
|
"vimball",
|
||||||
|
"vimballPlugin",
|
||||||
|
"zip",
|
||||||
|
"zipPlugin",
|
||||||
|
"tutor",
|
||||||
|
"rplugin",
|
||||||
|
"syntax",
|
||||||
|
"synmenu",
|
||||||
|
"optwin",
|
||||||
|
"compiler",
|
||||||
|
"bugreport",
|
||||||
|
"ftplugin",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
14
nvim/lua/configs/lspconfig.lua
Executable file
14
nvim/lua/configs/lspconfig.lua
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
local on_attach = require("nvchad.configs.lspconfig").on_attach
|
||||||
|
local capabilities = require("nvchad.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", "ts_ls", "clangd", "pyright", "vhdl_ls" }
|
||||||
|
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
lspconfig[lsp].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
end
|
||||||
19
nvim/lua/highlights.lua
Executable file
19
nvim/lua/highlights.lua
Executable 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
|
||||||
99
nvim/lua/mappings.lua
Executable file
99
nvim/lua/mappings.lua
Executable file
@@ -0,0 +1,99 @@
|
|||||||
|
require "nvchad.mappings"
|
||||||
|
|
||||||
|
local map = vim.keymap.set
|
||||||
|
|
||||||
|
map("n", ";", ":", { desc = "CMD enter command mode" })
|
||||||
|
|
||||||
|
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
|
||||||
|
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
|
||||||
|
-- empty mode is same as using <cmd> :map
|
||||||
|
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
|
||||||
|
map({ "n", "v", "x" }, "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { desc = "General Move down", expr = true })
|
||||||
|
map({ "n", "v", "x" }, "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { desc = "General Move up", expr = true })
|
||||||
|
map(
|
||||||
|
{ "n", "v", "x" },
|
||||||
|
"<Up>",
|
||||||
|
'v:count || mode(1)[0:1] == "no" ? "k" : "gk"',
|
||||||
|
{ desc = "General Move up", expr = true }
|
||||||
|
)
|
||||||
|
map(
|
||||||
|
{ "n", "v", "x" },
|
||||||
|
"<Down>",
|
||||||
|
'v:count || mode(1)[0:1] == "no" ? "j" : "gj"',
|
||||||
|
{ desc = "General Move down", expr = true }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Don't escape visual mode when indenting
|
||||||
|
map("v", "<", "<gv", { desc = "General Decrease indent" })
|
||||||
|
map("v", ">", ">gv", { desc = "General Increase indent" })
|
||||||
|
|
||||||
|
-- Don't copy the replaced text after pasting in visual mode
|
||||||
|
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
|
||||||
|
map("x", "p", 'p:let @+=@0<CR>:let @"=@0<CR>', { desc = "General Don't copy replaced text", silent = true })
|
||||||
|
|
||||||
|
-- format with conform
|
||||||
|
map("n", "<leader>fm", function()
|
||||||
|
require("conform").format()
|
||||||
|
end, { desc = "formatting" })
|
||||||
|
|
||||||
|
-- Trim trailing spaces
|
||||||
|
map("n", "<leader>s", function()
|
||||||
|
local curpos = vim.api.nvim_win_get_cursor(0)
|
||||||
|
vim.cmd [[keeppatterns %s/\s\+$//e]]
|
||||||
|
vim.api.nvim_win_set_cursor(0, curpos)
|
||||||
|
end, { desc = "Shortcuts Trim trailing whitespaces" })
|
||||||
|
|
||||||
|
-- Tabularize
|
||||||
|
map("n", "<Leader>t:", ":Tabularize /^[^:]*\\zs:<CR>", { desc = "Shortcuts tabularize :" })
|
||||||
|
map("n", "<Leader>t=", ":Tabularize /^[^7]*\\zs=><CR>", { desc = "Shortcuts tabularize =>" })
|
||||||
|
map(
|
||||||
|
"n",
|
||||||
|
"<Leader>ti",
|
||||||
|
":Tabularize /\\(\\<in\\>\\|\\<out\\>\\|\\<buffer\\>\\)<CR>",
|
||||||
|
{ desc = "Shortcuts tabularize port directions" }
|
||||||
|
)
|
||||||
|
map("v", "<Leader>t:", ":GTabularize /^[^:]*\\zs:<CR>", { desc = "Shortcuts block tabularize :" })
|
||||||
|
map("v", "<Leader>t=", ":GTabularize /^[^=]*\\zs=><CR>", { desc = "Shortcuts block tabularize =>" })
|
||||||
|
map(
|
||||||
|
"v",
|
||||||
|
"<Leader>ti",
|
||||||
|
":GTabularize /\\(\\<in\\>\\|\\<out\\>\\|\\<buffer\\>\\)<CR>",
|
||||||
|
{ desc = "Shortcuts block tabularize port directions" }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Gitsigns
|
||||||
|
map("n", "]c", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "]c"
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
require("gitsigns").next_hunk()
|
||||||
|
end)
|
||||||
|
return "<Ignore>"
|
||||||
|
end, { desc = "Gitsigns Jump to next hunk", expr = true })
|
||||||
|
|
||||||
|
map("n", "[c", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "[c"
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
require("gitsigns").prev_hunk()
|
||||||
|
end)
|
||||||
|
return "<Ignore>"
|
||||||
|
end, { desc = "Gitsigns Jump to prev hunk", expr = true })
|
||||||
|
|
||||||
|
map("n", "<leader>rh", function()
|
||||||
|
require("gitsigns").reset_hunk()
|
||||||
|
end, { desc = "Gitsigns Reset hunk" })
|
||||||
|
|
||||||
|
map("n", "<leader>ph", function()
|
||||||
|
require("gitsigns").preview_hunk()
|
||||||
|
end, { desc = "Gitsigns Preview hunk" })
|
||||||
|
|
||||||
|
map("n", "<leader>gb", function()
|
||||||
|
package.loaded.gitsigns.blame_line()
|
||||||
|
end, { desc = "Gitsigns Blame line" })
|
||||||
|
|
||||||
|
map("n", "<leader>td", function()
|
||||||
|
require("gitsigns").toggle_deleted()
|
||||||
|
end, { desc = "Gitsigns Toggle deleted" })
|
||||||
13
nvim/lua/myinit.lua
Executable file
13
nvim/lua/myinit.lua
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
|
|
||||||
|
-- Auto resize panes when resizing nvim window
|
||||||
|
-- autocmd("VimResized", {
|
||||||
|
-- pattern = "*",
|
||||||
|
-- command = "tabdo wincmd =",
|
||||||
|
-- })
|
||||||
|
|
||||||
|
-- Auto unfold all when entering a buffer
|
||||||
|
autocmd("BufWinEnter", { pattern = "*", command = "silent! :%foldopen!" })
|
||||||
|
|
||||||
|
vim.g.vscode_snippets_path = "~/.config/nvim/snippets"
|
||||||
|
vim.opt.relativenumber = true
|
||||||
11
nvim/lua/options.lua
Normal file
11
nvim/lua/options.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
require "nvchad.options"
|
||||||
|
|
||||||
|
-- add yours here!
|
||||||
|
|
||||||
|
-- local o = vim.o
|
||||||
|
-- o.cursorlineopt ='both' -- to enable cursorline!
|
||||||
|
|
||||||
|
local o = vim.o
|
||||||
|
-- Enable treesitter folding
|
||||||
|
o.foldmethod = "expr"
|
||||||
|
o.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
106
nvim/lua/plugins/init.lua
Normal file
106
nvim/lua/plugins/init.lua
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
-- event = 'BufWritePre', -- uncomment for format on save
|
||||||
|
config = function()
|
||||||
|
require "configs.conform"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
config = function()
|
||||||
|
require "nvchad.configs.lspconfig"
|
||||||
|
require "configs.lspconfig"
|
||||||
|
end, -- Override to setup mason-lspconfig
|
||||||
|
},
|
||||||
|
|
||||||
|
-- override plugin configs
|
||||||
|
{
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
opts = {
|
||||||
|
ensure_installed = {
|
||||||
|
-- lua stuff
|
||||||
|
"lua-language-server",
|
||||||
|
"stylua",
|
||||||
|
|
||||||
|
-- c/cpp stuff
|
||||||
|
"clangd",
|
||||||
|
"clang-format",
|
||||||
|
|
||||||
|
-- python
|
||||||
|
"pyright@1.1.351", -- newer versions have node skill issue
|
||||||
|
"autopep8",
|
||||||
|
|
||||||
|
-- latex/markdown stuff
|
||||||
|
"ltex-ls",
|
||||||
|
"bibtex-tidy",
|
||||||
|
|
||||||
|
-- shell
|
||||||
|
"shellcheck",
|
||||||
|
|
||||||
|
-- hdl
|
||||||
|
"rust_hdl",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
opts = {
|
||||||
|
ensure_installed = {
|
||||||
|
"vim",
|
||||||
|
"lua",
|
||||||
|
"html",
|
||||||
|
"css",
|
||||||
|
"c",
|
||||||
|
"cpp",
|
||||||
|
"markdown",
|
||||||
|
"markdown_inline",
|
||||||
|
"yaml",
|
||||||
|
"python",
|
||||||
|
"latex",
|
||||||
|
"vhdl",
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true,
|
||||||
|
-- disable = {
|
||||||
|
-- "python"
|
||||||
|
-- },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
opts = {
|
||||||
|
git = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
renderer = {
|
||||||
|
highlight_git = true,
|
||||||
|
icons = {
|
||||||
|
show = {
|
||||||
|
git = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
-- for users those who want auto-save conform + lazyloading!
|
||||||
|
event = "BufWritePre",
|
||||||
|
config = function()
|
||||||
|
require "configs.conform"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"godlygeek/tabular",
|
||||||
|
-- ft = "vhdl", -- temporary solution, but I only need it for vhdl. To be replaced with a real formatter long-term
|
||||||
|
cmd = { "GTabularize", "Tabularize" },
|
||||||
|
-- lazy = false
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user