Compare commits

..

18 Commits
v2.0 ... main

Author SHA1 Message Date
Pieter Joost van de Sande b913bdacfd fix: fix branch for base46 plugin
The base46 doesn't use the main branch for v1, but master.
2023-03-24 04:28:33 +05:30
siduck 3bacdf77b9 change branch names of nvchad plugins 2023-03-23 08:03:35 +05:30
Sidhanth Rathod b2cc8884e1
Update README.md 2023-03-12 11:38:56 +05:30
siduck 8cf7ca4002 lock nvim-web-devicons
this commit doesnt break our tabline, also read b2060eac2f (commitcomment-103397303)
2023-03-07 19:17:10 +05:30
kamack38 0371101121 Add cheatsheet.txt to .gitignore 2023-02-20 06:10:25 +05:30
siduck dc7d35d8a8 add v2.0 notice 2023-02-16 07:32:19 +05:30
Hossain Rizbi 32b0a008a9 fix: sumneko_lua is deprecated 2023-02-12 22:26:42 +05:30
Ryymm eac36d40bb fix: nvim-tree deprecation notice (#1755) 2023-01-31 06:46:00 +05:30
siduck d3ddae598f rm depreceated nvim-tree option (#1755) 2023-01-30 23:00:25 +05:30
Sidhanth Rathod 6d66f1df11
rm unneeded badge 2023-01-26 21:06:26 +05:30
anosillus b9ec202f79 remove kyazdani42 repo 2023-01-17 06:49:43 +05:30
siduck 178d62bce4 rm autocmd for autohiding statusline in alpha 2023-01-06 10:59:22 +05:30
Gazareth 9680078c6a refactor(alpha): Use terser way of checking vim.g.nvchad_vim_laststatus has not been set 2023-01-06 06:24:11 +05:30
Gazareth f67c629249 fix(dashboard): Use more robust method for toggling statusline 2023-01-06 06:24:11 +05:30
siduck e6a230129a rm old paypal link 2022-12-24 23:28:12 +05:30
Aaron 5e9ddcc1b0 Fix Capitalization and Typos 2022-12-24 23:25:48 +05:30
siduck 54b3649324 update tg group link in readme 2022-11-18 12:00:16 +05:30
siduck 65eab4535c rm title option
fixes (#1653) and this is a cmp issue + only with some terminals
2022-11-17 23:36:37 +05:30
37 changed files with 1399 additions and 896 deletions

161
.github/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,161 @@
# [CONTRIBUTING](https://nvchad.github.io/contribute)
## NvChad install for contributors
If you wish to contribute to NvChad, you should:
1. [create a fork on GitHub](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
2. clone your fork to your machine
- For ssh:
```shell
$ git clone git@github.com:<YOUR GITHUB USERNAME>/NvChad.git ~/.config/nvim
```
- For https:
```shell
$ git clone https://github.com/<YOUR GITHUB USERNAME>/NvChad.git ~/.config/nvim
```
3. [add a new remote repo to track](https://www.atlassian.com/git/tutorials/git-forks-and-upstreams)
- this means you can push/pull as normal to your own repo, but also easily track & update from the NvChad repo
- for ssh:
```shell
$ git remote add upstream git@github.com:NvChad/NvChad.git
```
- for https:
```shell
$ git remote add upstream https://github.com/NvChad/NvChad.git
```
4. any time you create a branch to do some work, use
```shell
$ git fetch upstream && git checkout -b dev-myFEAT upstream/main
```
5. only use the **--rebase** flag to update your dev branch
- this means that there are no `Merge NvChad/main into devBranch` commits, which are to be avoided
```shell
$ git pull upstream --rebase
```
## Things to know before contributing
- When making a PR (pull request), please be very descriptive about what you've done!
- PR titles should be formatted with 'fix', 'chore' or 'feat'. ex: `feat: add new plugin`
- PRs should follow the pull request formats where applicable
- We are open to all PRs, but may decline some for a myriad of reasons. Though don't be discouraged! We'll still be open to discussions.
- PR's are always welcomed however NvChad aims to be less bloated. So PR's regarding existing plugin's enhancement and creating new features with existing plugins itself ( without adding a new plugin), bug fixes and corrections are more encouraged.
- NvChad won't keep adding more and more features (like adding new plugins most likely) as requested if they feel unneeded and aren't usable by the majority!! If you think the plugin you want to be added is very useful and many NvChaders would find it useful, then such feature's PR is welcomed!
- But adding specific features like adding config for [wakatime](https://github.com/wakatime/vim-wakatime) etc will be added in this [chad user configs](https://github.com/NvChad/NvChad/wiki/Chad-user-configs). This lets the user select the things only they want ( adding configs from extra configs ).
## How to remove or edit commits from your PR
> You may have been directed here to remove a commit such as a merge commit: `Merge NvChad/main into devBranch` from your PR
> As these commands edit your git history, you may need to **force push** with `git push origin --force`
1. Run the following:
```
$ git rebase -i HEAD~<NUMBER OF COMMITS TO GO BACK>
```
<details><summary>Example</summary>
<p>
```shell
$ git rebase -i HEAD~4
```
```shell
pick 28b2dcb statusline add lsp status
pick dad9a39 feat: Added lsp radial progress
pick 68f72f1 add clickable btn for exiting nvim
pick b281b53 avoid using q! for quitting vim
# Rebase 52b655b..b281b53 onto 52b655b (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
```
</p>
</details>
2. Change the `pick` commands to whatever you wish, you may wish to `d` `drop` or `e` `edit` a commit. Then save & quit this git file to run it.
<details><summary>Example</summary>
<p>
```shell {3,4}
pick 28b2dcb statusline add lsp status
pick dad9a39 feat: Added lsp radial progress
edit 68f72f1 add clickable btn for exiting nvim
d b281b53 avoid using q! for quitting vim
# Rebase 52b655b..b281b53 onto 52b655b (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
```
</p>
</details>
3. If you picked `drop` you are done, if you picked `edit` then edit your files, then run:
```shell
$ git add <files>
```
4. Once you have edited & added your files, run:
```shell
$ git rebase --continue
```
5. You will likely need to push using:
```shell
$ git push origin --force
```
## Help
For help with contributing and anything else nvChad related join the [discord](https://discord.gg/VyPxsGArXc)

3
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,3 @@
patreon: siduck
ko_fi: siduck
custom: ["https://www.buymeacoffee.com/siduck", "https://www.paypal.com/paypalme/siduck76"]

34
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
<!-- Before reporting: update nvchad to the latest version,read breaking changes page,search existing issues. -->
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- Operating System
- Terminal
- Version of Neovim
**Additional context**
Add any other context about the problem here.

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Wiki
url: https://github.com/siduck76/NvChad/wiki
about: "Walks you through how to use and Configure NvChad."
- name: Visit our gitter chat
url: https://gitter.im/neovim-dotfiles/community
about: "A place where we dicuss NvChad related stuff."

View File

@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem was.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
**Screenshot**
Maybe a screenshot of the feature

View File

@ -0,0 +1,14 @@
Fixes Issue # (If it doesn't fix an issue then delete this line)
Features Added:
- Plugin Name (Add links if possible too)
Reasoning:
List why the feature is needed
Speed (If applicable):
Show the impact on the speed of nvChad
Other:
Anything else relevant goes here

16
.github/PULL_REQUEST_TEMPLATE/plugin.md vendored Normal file
View File

@ -0,0 +1,16 @@
(Make sure your title is either: 'fix', 'chore', or 'feat' then your title. ex: `fix: add new plugin`)
Fixes Issue # (If it doesn't fix an issue then delete this line)
Plugins Added:
- [Plugin Name](Plugin Link)
- [Plugin Name](Plugin Link)
Reasoning:
List why the plugin(s) should be added
Speed:
Show the impact on the speed of nvChad
Other:
Anything else relevant goes here

33
.github/README.md vendored Normal file
View File

@ -0,0 +1,33 @@
<h1 align="center">NvChad</h1>
<div align="center">
<a href="https://nvchad.github.io/">Home</a>
<span></span>
<a href="https://nvchad.github.io/quickstart/install">Install</a>
<span></span>
<a href="https://nvchad.github.io/contribute">Contribute</a>
<span></span>
<a href="https://github.com/NvChad/NvChad#gift_heart-support">Support</a>
<span></span>
<a href="https://nvchad.github.io/Features">Features</a>
<p></p>
</div>
<div align="center">
<a href="https://github.com/NvChad/NvChad/blob/main/LICENSE"
><img
src="https://img.shields.io/github/license/NvChad/NvChad?style=flat-square&logo=GNU&label=License&color=df967f"
alt="License"
/>
[![Neovim Minimum Version](https://img.shields.io/badge/Neovim-0.8.0-blueviolet.svg?style=flat-square&logo=Neovim&color=90E59A&logoColor=white)](https://github.com/neovim/neovim)
[![GitHub Issues](https://img.shields.io/github/issues/NvChad/NvChad.svg?style=flat-square&label=Issues&color=d77982)](https://github.com/NvChad/NvChad/issues)
[![Discord](https://img.shields.io/discord/869557815780470834?color=738adb&label=Discord&logo=discord&logoColor=white&style=flat-square)](https://discord.gg/gADmkJb9Fb)
[![Matrix](https://img.shields.io/badge/Matrix-40aa8b.svg?style=flat-square&logo=Matrix&logoColor=white)](https://matrix.to/#/#nvchad:matrix.org)
[![Telegram](https://img.shields.io/badge/Telegram-blue.svg?style=flat-square&logo=Telegram&logoColor=white)](https://t.me/nvchad_tg)
</div>
**NOTICE** : v2.0 is going to be released in this month. It uses lazy.nvim instead of packer and many new features have been added & performance improvements! working on the [docs](https://github.com/NvChad/nvchad.github.io/pull/118) currently and they will be more welcoming to newbies & would make you understand how nvchad works visually. To test v2.0 do a fresh clone of v2.0 branch ( do know that some of the lazy.nvim options are different from packer, [check](https://github.com/folke/lazy.nvim#packernvim) so you have to update the plugin options in your custom plugins table. )

22
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
exempt-all-issue-assignees: true # doesn't close an issue if someone was assigned to it.
close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.'
exempt-all-pr-assignees: true # doesn't close a pr if someone was assigned to it.
days-before-issue-stale: 30
days-before-pr-stale: 45
days-before-issue-close: 5
days-before-pr-close: 10

6
.gitignore vendored
View File

@ -1,9 +1,7 @@
plugin plugin
custom
spell spell
ftplugin ftplugin
syntax
coc-settings.json coc-settings.json
.luarc.json .luarc.json
lazy-lock.json cheatsheet.txt
after
.github

View File

@ -1 +0,0 @@
!/lua/custom/

View File

@ -1,21 +1,34 @@
vim.defer_fn(function()
pcall(require, "impatient")
end, 0)
require "core" require "core"
require "core.options"
local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1] -- setup packer + plugins
local fn = vim.fn
local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim"
if custom_init_path then if fn.empty(fn.glob(install_path)) > 0 then
dofile(custom_init_path) vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
print "Cloning packer .."
fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
-- install plugins + compile their configs
vim.cmd "packadd packer.nvim"
require "plugins"
vim.cmd "PackerSync"
-- install binaries from mason.nvim & tsparsers
vim.api.nvim_create_autocmd("User", {
pattern = "PackerComplete",
callback = function()
vim.cmd "bw | silent! MasonInstallAll" -- close packer window
require("packer").loader "nvim-treesitter"
end,
})
end end
pcall(require, "custom")
require("core.utils").load_mappings() require("core.utils").load_mappings()
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
-- bootstrap lazy.nvim!
if not vim.loop.fs_stat(lazypath) then
require("core.bootstrap").gen_chadrc_template()
require("core.bootstrap").lazy(lazypath)
end
dofile(vim.g.base46_cache .. "defaults")
vim.opt.rtp:prepend(lazypath)
require "plugins"

View File

@ -1,63 +0,0 @@
local M = {}
M.echo = function(str)
vim.cmd "redraw"
vim.api.nvim_echo({ { str, "Bold" } }, true, {})
end
local function shell_call(args)
local output = vim.fn.system(args)
assert(vim.v.shell_error == 0, "External call failed with error code: " .. vim.v.shell_error .. "\n" .. output)
end
M.lazy = function(install_path)
------------- base46 ---------------
local lazy_path = vim.fn.stdpath "data" .. "/lazy/base46"
M.echo " Compiling base46 theme to bytecode ..."
local base46_repo = "https://github.com/NvChad/base46"
shell_call { "git", "clone", "--depth", "1", "-b", "v2.0", base46_repo, lazy_path }
vim.opt.rtp:prepend(lazy_path)
require("base46").compile()
--------- lazy.nvim ---------------
M.echo " Installing lazy.nvim & plugins ..."
local repo = "https://github.com/folke/lazy.nvim.git"
shell_call { "git", "clone", "--filter=blob:none", "--branch=stable", repo, install_path }
vim.opt.rtp:prepend(install_path)
-- install plugins
require "plugins"
-- mason packages & show post_boostrap screen
require "nvchad.post_install"()
end
M.gen_chadrc_template = function()
if not vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] then
local path = vim.fn.stdpath "config" .. "/lua/custom/"
local input = "N"
if next(vim.api.nvim_list_uis()) then
input = vim.fn.input "Do you want to install example custom config? (y/N) : "
end
-- clone example_config repo
if input == "y" then
M.echo "cloning example custom config repo ..."
shell_call { "git", "clone", "--depth", "1", "https://github.com/NvChad/example_config", path }
vim.fn.delete(path .. ".git", "rf")
else
-- use very minimal chadrc
vim.fn.mkdir(path, "p")
local file = io.open(path .. "chadrc.lua", "w")
file:write "---@type ChadrcConfig \n local M = {}\n M.ui = {theme = 'onedark'}\n return M"
file:close()
end
end
end
return M

View File

@ -1,11 +1,15 @@
-- Chadrc overrides this file
local M = {} local M = {}
M.options = { M.options = {
nvchad_branch = "v2.0", nvChad = {
update_url = "https://github.com/NvChad/NvChad",
update_branch = "main",
},
} }
M.ui = { M.ui = {
------------------------------- base46 -------------------------------------
-- hl = highlights -- hl = highlights
hl_add = {}, hl_add = {},
hl_override = {}, hl_override = {},
@ -13,80 +17,11 @@ M.ui = {
theme_toggle = { "onedark", "one_light" }, theme_toggle = { "onedark", "one_light" },
theme = "onedark", -- default theme theme = "onedark", -- default theme
transparency = false, transparency = false,
lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens
-- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations
extended_integrations = {}, -- these aren't compiled by default, ex: "alpha", "notify"
-- cmp themeing
cmp = {
icons = true,
lspkind_text = true,
style = "default", -- default/flat_light/flat_dark/atom/atom_colored
border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables
selected_item_bg = "colored", -- colored / simple
},
telescope = { style = "borderless" }, -- borderless / bordered
------------------------------- nvchad_ui modules -----------------------------
statusline = {
theme = "default", -- 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 = "default",
overriden_modules = nil,
},
-- lazyload it when there are 1+ buffers
tabufline = {
show_numbers = false,
enabled = true,
lazyload = true,
overriden_modules = nil,
},
-- nvdash (dashboard)
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" },
},
},
cheatsheet = { theme = "grid" }, -- simple/grid
lsp = {
-- show function signatures i.e args as you type
signature = {
disabled = false,
silent = true, -- silences 'no signature help available' message from appearing
},
},
} }
M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file M.plugins = {}
M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options
-- check core.mappings for table structure
M.mappings = require "core.mappings" M.mappings = require "core.mappings"
return M return M

View File

@ -1,66 +1,14 @@
local opt = vim.opt
local g = vim.g
local config = require("core.utils").load_config()
-------------------------------------- globals -----------------------------------------
g.nvchad_theme = config.ui.theme
g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
g.toggle_theme_icon = ""
g.transparency = config.ui.transparency
-------------------------------------- options ------------------------------------------
opt.laststatus = 3 -- global statusline
opt.showmode = false
opt.clipboard = "unnamedplus"
opt.cursorline = true
-- Indenting
opt.expandtab = true
opt.shiftwidth = 2
opt.smartindent = true
opt.tabstop = 2
opt.softtabstop = 2
opt.fillchars = { eob = " " }
opt.ignorecase = true
opt.smartcase = true
opt.mouse = "a"
-- Numbers
opt.number = true
opt.numberwidth = 2
opt.ruler = false
-- disable nvim intro
opt.shortmess:append "sI"
opt.signcolumn = "yes"
opt.splitbelow = true
opt.splitright = true
opt.termguicolors = true
opt.timeoutlen = 400
opt.undofile = true
-- interval for writing swap file to disk, also used by gitsigns
opt.updatetime = 250
-- go to previous/next line with h,l,left arrow and right arrow
-- when cursor reaches end/beginning of line
opt.whichwrap:append "<>[]hl"
g.mapleader = " "
-- disable some default providers
for _, provider in ipairs { "node", "perl", "python3", "ruby" } do
vim.g["loaded_" .. provider .. "_provider"] = 0
end
-- add binaries installed by mason.nvim to path -- add binaries installed by mason.nvim to path
local is_windows = vim.loop.os_uname().sysname == "Windows_NT" local is_windows = vim.loop.os_uname().sysname == "Windows_NT"
vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH vim.env.PATH = vim.env.PATH .. (is_windows and ";" or ":") .. vim.fn.stdpath "data" .. "/mason/bin"
-------------------------------------- autocmds ------------------------------------------ -- commands
vim.cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
vim.cmd "silent! command! NvChadSnapshotCreate lua require('nvchad').snap_create()"
vim.cmd "silent! command! NvChadSnapshotDelete lua require('nvchad').snap_delete()"
vim.cmd "silent! command! NvChadSnapshotCheckout lua require('nvchad').snap_checkout()"
-- autocmds
local autocmd = vim.api.nvim_create_autocmd local autocmd = vim.api.nvim_create_autocmd
-- dont list quickfix buffers -- dont list quickfix buffers
@ -71,45 +19,9 @@ autocmd("FileType", {
end, end,
}) })
-- reload some chadrc options on-save -- wrap the PackerSync command to warn people before using it in NvChadSnapshots
autocmd("BufWritePost", { autocmd("VimEnter", {
pattern = vim.tbl_map(function(path) callback = function()
return vim.fs.normalize(vim.loop.fs_realpath(path)) vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('plugins') require('core.utils').packer_sync(<f-args>)"
end, vim.fn.glob(vim.fn.stdpath "config" .. "/lua/custom/**/*.lua", true, true, true)),
group = vim.api.nvim_create_augroup("ReloadNvChad", {}),
callback = function(opts)
local fp = vim.fn.fnamemodify(vim.fs.normalize(vim.api.nvim_buf_get_name(opts.buf)), ":r") --[[@as string]]
local app_name = vim.env.NVIM_APPNAME and vim.env.NVIM_APPNAME or "nvim"
local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".")
require("plenary.reload").reload_module "base46"
require("plenary.reload").reload_module(module)
require("plenary.reload").reload_module "custom.chadrc"
config = require("core.utils").load_config()
vim.g.nvchad_theme = config.ui.theme
vim.g.transparency = config.ui.transparency
-- statusline
require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme)
vim.opt.statusline = "%!v:lua.require('nvchad.statusline." .. config.ui.statusline.theme .. "').run()"
-- tabufline
if config.ui.tabufline.enabled then
require("plenary.reload").reload_module "nvchad.tabufline.modules"
vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules').run()"
end
require("base46").load_all_highlights()
-- vim.cmd("redraw!")
end, end,
}) })
-------------------------------------- commands ------------------------------------------
local new_cmd = vim.api.nvim_create_user_command
new_cmd("NvChadUpdate", function()
require "nvchad.updater"()
end, {})

79
lua/core/lazy_load.lua Normal file
View File

@ -0,0 +1,79 @@
local M = {}
local autocmd = vim.api.nvim_create_autocmd
-- require("packer").loader(tb.plugins)
-- This must be used for plugins that need to be loaded just after a file
-- ex : treesitter, lspconfig etc
M.lazy_load = function(tb)
autocmd(tb.events, {
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
callback = function()
if tb.condition() then
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
-- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename"
if tb.plugin ~= "nvim-treesitter" then
vim.defer_fn(function()
require("packer").loader(tb.plugin)
if tb.plugin == "nvim-lspconfig" then
vim.cmd "silent! do FileType"
end
end, 0)
else
require("packer").loader(tb.plugin)
end
end
end,
})
end
-- load certain plugins only when there's a file opened in the buffer
-- if "nvim filename" is executed -> load the plugin after nvim gui loads
-- This gives an instant preview of nvim with the file opened
M.on_file_open = function(plugin_name)
M.lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
plugin = plugin_name,
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
end,
}
end
M.packer_cmds = {
"PackerSnapshot",
"PackerSnapshotRollback",
"PackerSnapshotDelete",
"PackerInstall",
"PackerUpdate",
"PackerSync",
"PackerClean",
"PackerCompile",
"PackerStatus",
"PackerProfile",
"PackerLoad",
}
M.treesitter_cmds = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" }
M.mason_cmds = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }
M.gitsigns = function()
autocmd({ "BufRead" }, {
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
callback = function()
vim.fn.system("git -C " .. vim.fn.expand "%:p:h" .. " rev-parse")
if vim.v.shell_error == 0 then
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
vim.schedule(function()
require("packer").loader "gitsigns.nvim"
end)
end
end,
})
end
return M

View File

@ -1,74 +1,79 @@
-- n, v, i, t = mode names -- n, v, i, t = mode names
local function termcodes(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local M = {} local M = {}
M.general = { M.general = {
i = { i = {
-- go to beginning and end -- go to beginning and end
["<C-b>"] = { "<ESC>^i", "Beginning of line" }, ["<C-b>"] = { "<ESC>^i", "beginning of line" },
["<C-e>"] = { "<End>", "End of line" }, ["<C-e>"] = { "<End>", "end of line" },
-- navigate within insert mode -- navigate within insert mode
["<C-h>"] = { "<Left>", "Move left" }, ["<C-h>"] = { "<Left>", "move left" },
["<C-l>"] = { "<Right>", "Move right" }, ["<C-l>"] = { "<Right>", "move right" },
["<C-j>"] = { "<Down>", "Move down" }, ["<C-j>"] = { "<Down>", "move down" },
["<C-k>"] = { "<Up>", "Move up" }, ["<C-k>"] = { "<Up>", "move up" },
}, },
n = { n = {
["<Esc>"] = { ":noh <CR>", "Clear highlights" }, ["<ESC>"] = { "<cmd> noh <CR>", "no highlight" },
-- switch between windows -- switch between windows
["<C-h>"] = { "<C-w>h", "Window left" }, ["<C-h>"] = { "<C-w>h", "window left" },
["<C-l>"] = { "<C-w>l", "Window right" }, ["<C-l>"] = { "<C-w>l", "window right" },
["<C-j>"] = { "<C-w>j", "Window down" }, ["<C-j>"] = { "<C-w>j", "window down" },
["<C-k>"] = { "<C-w>k", "Window up" }, ["<C-k>"] = { "<C-w>k", "window up" },
-- save -- save
["<C-s>"] = { "<cmd> w <CR>", "Save file" }, ["<C-s>"] = { "<cmd> w <CR>", "save file" },
-- Copy all -- Copy all
["<C-c>"] = { "<cmd> %y+ <CR>", "Copy whole file" }, ["<C-c>"] = { "<cmd> %y+ <CR>", "copy whole file" },
-- line numbers -- line numbers
["<leader>n"] = { "<cmd> set nu! <CR>", "Toggle line number" }, ["<leader>n"] = { "<cmd> set nu! <CR>", "toggle line number" },
["<leader>rn"] = { "<cmd> set rnu! <CR>", "Toggle relative number" }, ["<leader>rn"] = { "<cmd> set rnu! <CR>", "toggle relative number" },
-- update nvchad
["<leader>uu"] = { "<cmd> :NvChadUpdate <CR>", "update nvchad" },
["<leader>tt"] = {
function()
require("base46").toggle_theme()
end,
"toggle theme",
},
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down> -- 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/ -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
-- empty mode is same as using <cmd> :map -- 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 -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, ["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, ["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- new buffer -- new buffer
["<leader>b"] = { "<cmd> enew <CR>", "New buffer" }, ["<leader>b"] = { "<cmd> enew <CR>", "new buffer" },
["<leader>ch"] = { "<cmd> NvCheatsheet <CR>", "Mapping cheatsheet" },
["<leader>fm"] = {
function()
vim.lsp.buf.format { async = true }
end,
"LSP formatting",
},
}, },
t = { t = { ["<C-x>"] = { termcodes "<C-\\><C-N>", "escape terminal mode" } },
["<C-x>"] = { vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true), "Escape terminal mode" },
},
v = { v = {
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, ["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, ["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
}, },
x = { x = {
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
-- Don't copy the replaced text after pasting in visual mode -- 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 -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', "Dont copy replaced text", opts = { silent = true } }, ["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', opts = { silent = true } },
}, },
} }
@ -77,26 +82,29 @@ M.tabufline = {
n = { n = {
-- cycle through buffers -- cycle through buffers
["<tab>"] = { ["<TAB>"] = {
function() function()
require("nvchad.tabufline").tabuflineNext() require("nvchad_ui.tabufline").tabuflineNext()
end, end,
"Goto next buffer", "goto next buffer",
}, },
["<S-tab>"] = { ["<S-Tab>"] = {
function() function()
require("nvchad.tabufline").tabuflinePrev() require("nvchad_ui.tabufline").tabuflinePrev()
end, end,
"Goto prev buffer", "goto prev buffer",
}, },
-- pick buffers via numbers
["<Bslash>"] = { "<cmd> TbufPick <CR>", "Pick buffer" },
-- close buffer + hide terminal buffer -- close buffer + hide terminal buffer
["<leader>x"] = { ["<leader>x"] = {
function() function()
require("nvchad.tabufline").close_buffer() require("nvchad_ui.tabufline").close_buffer()
end, end,
"Close buffer", "close buffer",
}, },
}, },
} }
@ -110,14 +118,14 @@ M.comment = {
function() function()
require("Comment.api").toggle.linewise.current() require("Comment.api").toggle.linewise.current()
end, end,
"Toggle comment", "toggle comment",
}, },
}, },
v = { v = {
["<leader>/"] = { ["<leader>/"] = {
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>", "<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
"Toggle comment", "toggle comment",
}, },
}, },
} }
@ -132,112 +140,119 @@ M.lspconfig = {
function() function()
vim.lsp.buf.declaration() vim.lsp.buf.declaration()
end, end,
"LSP declaration", "lsp declaration",
}, },
["gd"] = { ["gd"] = {
function() function()
vim.lsp.buf.definition() vim.lsp.buf.definition()
end, end,
"LSP definition", "lsp definition",
}, },
["K"] = { ["K"] = {
function() function()
vim.lsp.buf.hover() vim.lsp.buf.hover()
end, end,
"LSP hover", "lsp hover",
}, },
["gi"] = { ["gi"] = {
function() function()
vim.lsp.buf.implementation() vim.lsp.buf.implementation()
end, end,
"LSP implementation", "lsp implementation",
}, },
["<leader>ls"] = { ["<leader>ls"] = {
function() function()
vim.lsp.buf.signature_help() vim.lsp.buf.signature_help()
end, end,
"LSP signature help", "lsp signature_help",
}, },
["<leader>D"] = { ["<leader>D"] = {
function() function()
vim.lsp.buf.type_definition() vim.lsp.buf.type_definition()
end, end,
"LSP definition type", "lsp definition type",
}, },
["<leader>ra"] = { ["<leader>ra"] = {
function() function()
require("nvchad.renamer").open() require("nvchad_ui.renamer").open()
end, end,
"LSP rename", "lsp rename",
}, },
["<leader>ca"] = { ["<leader>ca"] = {
function() function()
vim.lsp.buf.code_action() vim.lsp.buf.code_action()
end, end,
"LSP code action", "lsp code_action",
}, },
["gr"] = { ["gr"] = {
function() function()
vim.lsp.buf.references() vim.lsp.buf.references()
end, end,
"LSP references", "lsp references",
}, },
["<leader>f"] = { ["<leader>f"] = {
function() function()
vim.diagnostic.open_float { border = "rounded" } vim.diagnostic.open_float()
end, end,
"Floating diagnostic", "floating diagnostic",
}, },
["[d"] = { ["[d"] = {
function() function()
vim.diagnostic.goto_prev { float = { border = "rounded" } } vim.diagnostic.goto_prev()
end, end,
"Goto prev", "goto prev",
}, },
["]d"] = { ["d]"] = {
function() function()
vim.diagnostic.goto_next { float = { border = "rounded" } } vim.diagnostic.goto_next()
end, end,
"Goto next", "goto_next",
}, },
["<leader>q"] = { ["<leader>q"] = {
function() function()
vim.diagnostic.setloclist() vim.diagnostic.setloclist()
end, end,
"Diagnostic setloclist", "diagnostic setloclist",
},
["<leader>fm"] = {
function()
vim.lsp.buf.format { async = true }
end,
"lsp formatting",
}, },
["<leader>wa"] = { ["<leader>wa"] = {
function() function()
vim.lsp.buf.add_workspace_folder() vim.lsp.buf.add_workspace_folder()
end, end,
"Add workspace folder", "add workspace folder",
}, },
["<leader>wr"] = { ["<leader>wr"] = {
function() function()
vim.lsp.buf.remove_workspace_folder() vim.lsp.buf.remove_workspace_folder()
end, end,
"Remove workspace folder", "remove workspace folder",
}, },
["<leader>wl"] = { ["<leader>wl"] = {
function() function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, end,
"List workspace folders", "list workspace folders",
}, },
}, },
} }
@ -247,10 +262,10 @@ M.nvimtree = {
n = { n = {
-- toggle -- toggle
["<C-n>"] = { "<cmd> NvimTreeToggle <CR>", "Toggle nvimtree" }, ["<C-n>"] = { "<cmd> NvimTreeToggle <CR>", "toggle nvimtree" },
-- focus -- focus
["<leader>e"] = { "<cmd> NvimTreeFocus <CR>", "Focus nvimtree" }, ["<leader>e"] = { "<cmd> NvimTreeFocus <CR>", "focus nvimtree" },
}, },
} }
@ -259,25 +274,23 @@ M.telescope = {
n = { n = {
-- find -- find
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "Find files" }, ["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "find files" },
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "Find all" }, ["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "find all" },
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "Live grep" }, ["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "Find buffers" }, ["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "find buffers" },
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "Help page" }, ["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "help page" },
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "Find oldfiles" }, ["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "find oldfiles" },
["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" }, ["<leader>tk"] = { "<cmd> Telescope keymaps <CR>", "show keys" },
-- git -- git
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "Git commits" }, ["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "git commits" },
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "Git status" }, ["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "git status" },
-- pick a hidden term -- pick a hidden term
["<leader>pt"] = { "<cmd> Telescope terms <CR>", "Pick hidden term" }, ["<leader>pt"] = { "<cmd> Telescope terms <CR>", "pick hidden term" },
-- theme switcher -- theme switcher
["<leader>th"] = { "<cmd> Telescope themes <CR>", "Nvchad themes" }, ["<leader>th"] = { "<cmd> Telescope themes <CR>", "nvchad themes" },
["<leader>ma"] = { "<cmd> Telescope marks <CR>", "telescope bookmarks" },
}, },
} }
@ -290,21 +303,21 @@ M.nvterm = {
function() function()
require("nvterm.terminal").toggle "float" require("nvterm.terminal").toggle "float"
end, end,
"Toggle floating term", "toggle floating term",
}, },
["<A-h>"] = { ["<A-h>"] = {
function() function()
require("nvterm.terminal").toggle "horizontal" require("nvterm.terminal").toggle "horizontal"
end, end,
"Toggle horizontal term", "toggle horizontal term",
}, },
["<A-v>"] = { ["<A-v>"] = {
function() function()
require("nvterm.terminal").toggle "vertical" require("nvterm.terminal").toggle "vertical"
end, end,
"Toggle vertical term", "toggle vertical term",
}, },
}, },
@ -314,36 +327,37 @@ M.nvterm = {
function() function()
require("nvterm.terminal").toggle "float" require("nvterm.terminal").toggle "float"
end, end,
"Toggle floating term", "toggle floating term",
}, },
["<A-h>"] = { ["<A-h>"] = {
function() function()
require("nvterm.terminal").toggle "horizontal" require("nvterm.terminal").toggle "horizontal"
end, end,
"Toggle horizontal term", "toggle horizontal term",
}, },
["<A-v>"] = { ["<A-v>"] = {
function() function()
require("nvterm.terminal").toggle "vertical" require("nvterm.terminal").toggle "vertical"
end, end,
"Toggle vertical term", "toggle vertical term",
}, },
-- new -- new
["<leader>h"] = { ["<leader>h"] = {
function() function()
require("nvterm.terminal").new "horizontal" require("nvterm.terminal").new "horizontal"
end, end,
"New horizontal term", "new horizontal term",
}, },
["<leader>v"] = { ["<leader>v"] = {
function() function()
require("nvterm.terminal").new "vertical" require("nvterm.terminal").new "vertical"
end, end,
"New vertical term", "new vertical term",
}, },
}, },
} }
@ -356,14 +370,14 @@ M.whichkey = {
function() function()
vim.cmd "WhichKey" vim.cmd "WhichKey"
end, end,
"Which-key all keymaps", "which-key all keymaps",
}, },
["<leader>wk"] = { ["<leader>wk"] = {
function() function()
local input = vim.fn.input "WhichKey: " local input = vim.fn.input "WhichKey: "
vim.cmd("WhichKey " .. input) vim.cmd("WhichKey " .. input)
end, end,
"Which-key query lookup", "which-key query lookup",
}, },
}, },
} }
@ -385,7 +399,7 @@ M.blankline = {
end end
end, end,
"Jump to current context", "Jump to current_context",
}, },
}, },
} }

95
lua/core/options.lua Normal file
View File

@ -0,0 +1,95 @@
local opt = vim.opt
local g = vim.g
local config = require("core.utils").load_config()
g.nvchad_theme = config.ui.theme
g.toggle_theme_icon = ""
g.transparency = config.ui.transparency
g.theme_switcher_loaded = false
opt.laststatus = 3 -- global statusline
opt.showmode = false
opt.clipboard = "unnamedplus"
opt.cursorline = true
-- Indenting
opt.expandtab = true
opt.shiftwidth = 2
opt.smartindent = true
opt.tabstop = 2
opt.softtabstop = 2
opt.fillchars = { eob = " " }
opt.ignorecase = true
opt.smartcase = true
opt.mouse = "a"
-- Numbers
opt.number = true
opt.numberwidth = 2
opt.ruler = false
-- disable nvim intro
opt.shortmess:append "sI"
opt.signcolumn = "yes"
opt.splitbelow = true
opt.splitright = true
opt.termguicolors = true
opt.timeoutlen = 400
opt.undofile = true
-- interval for writing swap file to disk, also used by gitsigns
opt.updatetime = 250
-- go to previous/next line with h,l,left arrow and right arrow
-- when cursor reaches end/beginning of line
opt.whichwrap:append "<>[]hl"
g.mapleader = " "
-- disable some builtin vim plugins
local default_plugins = {
"2html_plugin",
"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",
}
for _, plugin in pairs(default_plugins) do
g["loaded_" .. plugin] = 1
end
local default_providers = {
"node",
"perl",
"python3",
"ruby",
}
for _, provider in ipairs(default_providers) do
vim.g["loaded_" .. provider .. "_provider"] = 0
end

View File

@ -3,16 +3,19 @@ local merge_tb = vim.tbl_deep_extend
M.load_config = function() M.load_config = function()
local config = require "core.default_config" local config = require "core.default_config"
local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] local chadrc_exists, chadrc = pcall(require, "custom.chadrc")
if chadrc_path then
local chadrc = dofile(chadrc_path)
if chadrc_exists then
-- merge user config if it exists and is a table; otherwise display an error
if type(chadrc) == "table" then
config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings)
config = merge_tb("force", config, chadrc) config = merge_tb("force", config, chadrc) or {}
config.mappings.disabled = nil else
error "chadrc must return a table!"
end
end end
config.mappings.disabled = nil
return config return config
end end
@ -52,12 +55,10 @@ M.remove_disabled_keys = function(chadrc_mappings, default_mappings)
end end
M.load_mappings = function(section, mapping_opt) M.load_mappings = function(section, mapping_opt)
vim.schedule(function()
local function set_section_map(section_values) local function set_section_map(section_values)
if section_values.plugin then if section_values.plugin then
return return
end end
section_values.plugin = nil section_values.plugin = nil
for mode, mode_values in pairs(section_values) do for mode, mode_values in pairs(section_values) do
@ -84,35 +85,108 @@ M.load_mappings = function(section, mapping_opt)
for _, sect in pairs(mappings) do for _, sect in pairs(mappings) do
set_section_map(sect) set_section_map(sect)
end end
end)
end end
M.lazy_load = function(plugin) -- merge default/user plugin tables
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, { M.merge_plugins = function(plugins)
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}), local plugin_configs = M.load_config().plugins
callback = function() local user_plugins = plugin_configs
local file = vim.fn.expand "%"
local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= ""
if condition then -- old plugin syntax for adding plugins
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin) if plugin_configs.user and type(plugin_configs.user) == "table" then
user_plugins = plugin_configs.user
-- dont defer for treesitter as it will show slow highlighting end
-- This deferring only happens only when we do "nvim filename"
if plugin ~= "nvim-treesitter" then -- support old plugin removal syntax
vim.schedule(function() local remove_plugins = plugin_configs.remove
require("lazy").load { plugins = plugin } if type(remove_plugins) == "table" then
for _, v in ipairs(remove_plugins) do
if plugin == "nvim-lspconfig" then plugins[v] = nil
vim.cmd "silent! do FileType" end
end
plugins = merge_tb("force", plugins, user_plugins)
local final_table = {}
for key, val in pairs(plugins) do
if val and type(val) == "table" then
plugins[key] = val.rm_default_opts and user_plugins[key] or plugins[key]
plugins[key][1] = key
final_table[#final_table + 1] = plugins[key]
end
end
return final_table
end
-- override plugin options table with custom ones
M.load_override = function(options_table, name)
local plugin_configs, plugin_options = M.load_config().plugins, nil
-- support old plugin syntax for override
local user_override = plugin_configs.override and plugin_configs.override[name]
if user_override and type(user_override) == "table" then
plugin_options = user_override
end
-- if no old style plugin override is found, then use the new syntax
if not plugin_options and plugin_configs[name] then
local override_options = plugin_configs[name].override_options or {}
if type(override_options) == "table" then
plugin_options = override_options
elseif type(override_options) == "function" then
plugin_options = override_options()
end
end
-- make sure the plugin options are a table
plugin_options = type(plugin_options) == "table" and plugin_options or {}
return merge_tb("force", options_table, plugin_options)
end
M.packer_sync = function(...)
local git_exists, git = pcall(require, "nvchad.utils.git")
local defaults_exists, defaults = pcall(require, "nvchad.utils.config")
local packer_exists, packer = pcall(require, "packer")
if git_exists and defaults_exists then
local current_branch_name = git.get_current_branch_name()
-- warn the user if we are on a snapshot branch
if current_branch_name:match(defaults.snaps.base_snap_branch_name .. "(.+)" .. "$") then
vim.api.nvim_echo({
{ "WARNING: You are trying to use ", "WarningMsg" },
{ "PackerSync" },
{
" on a NvChadSnapshot. This will cause issues if NvChad dependencies contain "
.. "any breaking changes! Plugin updates will not be included in this "
.. "snapshot, so they will be lost after switching between snapshots! Would "
.. "you still like to continue? [y/N]\n",
"WarningMsg",
},
}, false, {})
local ans = vim.trim(string.lower(vim.fn.input "-> "))
if ans ~= "y" then
return
end
end
end
if packer_exists then
packer.sync(...)
local plugins = M.load_config().plugins
local old_style_options = plugins.user or plugins.override or plugins.remove
if old_style_options then
vim.notify_once("NvChad: This plugin syntax is deprecated, use new style config.", "Error")
end end
end, 0)
else else
require("lazy").load { plugins = plugin } error "Packer could not be loaded!"
end end
end
end,
})
end end
return M return M

View File

@ -1,6 +0,0 @@
---@type ChadrcConfig
local M = {}
M.ui = {theme = 'gatekeeper'}
M.plugins = 'custom.plugins'
M.mappings = require "custom.mappings"
return M

View File

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

View File

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

View File

@ -1,6 +0,0 @@
vim.opt.colorcolumn = "180"
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 0
vim.opt.shiftwidth = 0

View File

@ -1,30 +0,0 @@
local M = {}
M.dap = {
n = {
["<leader>db"] = {
"<cmd> DapToggleBreakpoint <CR>",
"Toggle Breakpoint"
},
["<leader>dus"] = {
function ()
local widgets = require("dap.ui.widgets");
local sidebar = widgets.sidebar(widgets.scopes);
sidebar.open();
end,
"Open debugging sidebar"
},
["<leader>dc"] = {
"<cmd> DapContinue <CR>",
"Continue debugging"
},
["<leader>rcu"] = {
function ()
require("crates").upgrade_all_crates()
end,
"Update all rust crates"
}
}
}
return M

View File

@ -1,57 +0,0 @@
local plugins = {
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end
},
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"lua-language-server",
"rust-analyzer"
}
}
},
{
"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 "custom.configs.rust-tools"
end,
config = function (_, opts)
require("rust-tools").setup(opts)
end
},
{
"mfussenegger/nvim-dap"
},
{
"saecki/crates.nvim",
ft = {"rust", "toml"},
config = function (_, opts)
local crates = require("crates")
crates.setup(opts)
crates.show()
end
},
{
"hrsh7th/nvim-cmp",
opts = function ()
local M = require "plugins.configs.cmp"
table.insert(M.sources, {name = "crates"})
return M
end
}
}
return plugins

View File

@ -0,0 +1,94 @@
local present, alpha = pcall(require, "alpha")
if not present then
return
end
require("base46").load_highlight "alpha"
local function button(sc, txt, keybind)
local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>")
local opts = {
position = "center",
text = txt,
shortcut = sc,
cursor = 5,
width = 36,
align_shortcut = "right",
hl = "AlphaButtons",
}
if keybind then
opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } }
end
return {
type = "button",
val = txt,
on_press = function()
local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) or ""
vim.api.nvim_feedkeys(key, "normal", false)
end,
opts = opts,
}
end
-- dynamic header padding
local fn = vim.fn
local marginTopPercent = 0.3
local headerPadding = fn.max { 2, fn.floor(fn.winheight(0) * marginTopPercent) }
local options = {
header = {
type = "text",
val = {
" ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ",
" ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ",
" ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ",
" ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ",
" ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ",
" ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ",
" ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ",
" ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ",
" ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ",
" ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ",
" ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ",
},
opts = {
position = "center",
hl = "AlphaHeader",
},
},
buttons = {
type = "group",
val = {
button("SPC f f", " Find File ", ":Telescope find_files<CR>"),
button("SPC f o", " Recent File ", ":Telescope oldfiles<CR>"),
button("SPC f w", " Find Word ", ":Telescope live_grep<CR>"),
button("SPC b m", " Bookmarks ", ":Telescope marks<CR>"),
button("SPC t h", " Themes ", ":Telescope themes<CR>"),
button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h <CR>"),
},
opts = {
spacing = 1,
},
},
headerPaddingTop = { type = "padding", val = headerPadding },
headerPaddingBottom = { type = "padding", val = 2 },
}
options = require("core.utils").load_override(options, "goolord/alpha-nvim")
alpha.setup {
layout = {
options.headerPaddingTop,
options.header,
options.headerPaddingBottom,
options.buttons,
},
opts = {},
}

View File

@ -1,35 +1,12 @@
local cmp = require "cmp" local present, cmp = pcall(require, "cmp")
dofile(vim.g.base46_cache .. "cmp") if not present then
return
end
local cmp_ui = require("core.utils").load_config().ui.cmp require("base46").load_highlight "cmp"
local cmp_style = cmp_ui.style
local field_arrangement = { vim.o.completeopt = "menu,menuone,noselect"
atom = { "kind", "abbr", "menu" },
atom_colored = { "kind", "abbr", "menu" },
}
local formatting_style = {
-- default fields order i.e completion word + item.kind + item.kind icons
fields = field_arrangement[cmp_style] or { "abbr", "kind", "menu" },
format = function(_, item)
local icons = require "nvchad.icons.lspkind"
local icon = (cmp_ui.icons and icons[item.kind]) or ""
if cmp_style == "atom" or cmp_style == "atom_colored" then
icon = " " .. icon .. " "
item.menu = cmp_ui.lspkind_text and " (" .. item.kind .. ")" or ""
item.kind = icon
else
icon = cmp_ui.lspkind_text and (" " .. icon .. " ") or icon
item.kind = string.format("%s %s", icon, cmp_ui.lspkind_text and item.kind or "")
end
return item
end,
}
local function border(hl_name) local function border(hl_name)
return { return {
@ -44,20 +21,23 @@ local function border(hl_name)
} }
end end
local options = { local cmp_window = require "cmp.utils.window"
completion = {
completeopt = "menu,menuone",
},
cmp_window.info_ = cmp_window.info
cmp_window.info = function(self)
local info = self:info_()
info.scrollable = false
return info
end
local options = {
window = { window = {
completion = { completion = {
side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0, border = border "CmpBorder",
winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel", winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
scrollbar = false,
}, },
documentation = { documentation = {
border = border "CmpDocBorder", border = border "CmpDocBorder",
winhighlight = "Normal:CmpDoc",
}, },
}, },
snippet = { snippet = {
@ -65,9 +45,13 @@ local options = {
require("luasnip").lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end, end,
}, },
formatting = {
formatting = formatting_style, format = function(_, vim_item)
local icons = require("nvchad_ui.icons").lspkind
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
return vim_item
end,
},
mapping = { mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(), ["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(), ["<C-n>"] = cmp.mapping.select_next_item(),
@ -76,8 +60,8 @@ local options = {
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(), ["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { ["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = false,
}, },
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
@ -105,16 +89,15 @@ local options = {
}), }),
}, },
sources = { sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "buffer" }, { name = "buffer" },
{ name = "nvim_lua" }, { name = "nvim_lua" },
{ name = "path" }, { name = "path" },
}, },
} }
if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then -- check for any override
options.window.completion.border = border "CmpBorder" options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp")
end
return options cmp.setup(options)

View File

@ -1,47 +0,0 @@
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",
},
},
},
}

View File

@ -1,5 +1,11 @@
dofile(vim.g.base46_cache .. "lsp") local present, lspconfig = pcall(require, "lspconfig")
require "nvchad.lsp"
if not present then
return
end
require("base46").load_highlight "lsp"
require "nvchad_ui.lsp"
local M = {} local M = {}
local utils = require "core.utils" local utils = require "core.utils"
@ -13,11 +19,7 @@ M.on_attach = function(client, bufnr)
utils.load_mappings("lspconfig", { buffer = bufnr }) utils.load_mappings("lspconfig", { buffer = bufnr })
if client.server_capabilities.signatureHelpProvider then if client.server_capabilities.signatureHelpProvider then
require("nvchad.signature").setup(client) require("nvchad_ui.signature").setup(client)
end
if not utils.load_config().ui.lsp_semantic_tokens and client.supports_method "textDocument/semanticTokens" then
client.server_capabilities.semanticTokensProvider = nil
end end
end end
@ -41,7 +43,7 @@ M.capabilities.textDocument.completion.completionItem = {
}, },
} }
require("lspconfig").lua_ls.setup { lspconfig.lua_ls.setup {
on_attach = M.on_attach, on_attach = M.on_attach,
capabilities = M.capabilities, capabilities = M.capabilities,
@ -54,8 +56,6 @@ require("lspconfig").lua_ls.setup {
library = { library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true, [vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
[vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true,
[vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
}, },
maxPreload = 100000, maxPreload = 100000,
preloadFileSize = 10000, preloadFileSize = 10000,

View File

@ -1,3 +1,18 @@
local present, mason = pcall(require, "mason")
if not present then
return
end
vim.api.nvim_create_augroup("_mason", { clear = true })
vim.api.nvim_create_autocmd("Filetype", {
pattern = "mason",
callback = function()
require("base46").load_highlight "mason"
end,
group = "_mason",
})
local options = { local options = {
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
@ -6,8 +21,8 @@ local options = {
ui = { ui = {
icons = { icons = {
package_pending = "", package_pending = "",
package_installed = "󰄳 ", package_installed = " ",
package_uninstalled = " 󰚌", package_uninstalled = " ",
}, },
keymaps = { keymaps = {
@ -25,4 +40,10 @@ local options = {
max_concurrent_installers = 10, max_concurrent_installers = 10,
} }
return options options = require("core.utils").load_override(options, "williamboman/mason.nvim")
vim.api.nvim_create_user_command("MasonInstallAll", function()
vim.cmd("MasonInstall " .. table.concat(options.ensure_installed, " "))
end, {})
mason.setup(options)

View File

@ -1,3 +1,11 @@
local present, nvimtree = pcall(require, "nvim-tree")
if not present then
return
end
require("base46").load_highlight "nvimtree"
local options = { local options = {
filters = { filters = {
dotfiles = false, dotfiles = false,
@ -7,16 +15,16 @@ local options = {
hijack_netrw = true, hijack_netrw = true,
hijack_cursor = true, hijack_cursor = true,
hijack_unnamed_buffer_when_opening = false, hijack_unnamed_buffer_when_opening = false,
sync_root_with_cwd = true, update_cwd = true,
update_focused_file = { update_focused_file = {
enable = true, enable = true,
update_root = false, update_cwd = false,
}, },
view = { view = {
adaptive_size = false, adaptive_size = true,
side = "left", side = "left",
width = 30, width = 25,
preserve_window_proportions = true, hide_root_folder = true,
}, },
git = { git = {
enable = false, enable = false,
@ -31,7 +39,6 @@ local options = {
}, },
}, },
renderer = { renderer = {
root_folder_label = false,
highlight_git = false, highlight_git = false,
highlight_opened_files = "none", highlight_opened_files = "none",
@ -48,22 +55,22 @@ local options = {
}, },
glyphs = { glyphs = {
default = "󰈚", default = "",
symlink = "", symlink = "",
folder = { folder = {
default = "", default = "",
empty = "", empty = "",
empty_open = "", empty_open = "",
open = "", open = "",
symlink = "", symlink = "",
symlink_open = "", symlink_open = "",
arrow_open = "", arrow_open = "",
arrow_closed = "", arrow_closed = "",
}, },
git = { git = {
unstaged = "", unstaged = "",
staged = "", staged = "",
unmerged = "", unmerged = "",
renamed = "", renamed = "",
untracked = "", untracked = "",
deleted = "", deleted = "",
@ -74,4 +81,8 @@ local options = {
}, },
} }
return options -- check for any override
options = require("core.utils").load_override(options, "nvim-tree/nvim-tree.lua")
vim.g.nvimtree_side = options.view.side
nvimtree.setup(options)

View File

@ -0,0 +1,34 @@
local present, nvterm = pcall(require, "nvterm")
if not present then
return
end
require "base46.term"
local options = {
terminals = {
list = {},
type_opts = {
float = {
relative = "editor",
row = 0.3,
col = 0.25,
width = 0.5,
height = 0.4,
border = "single",
},
horizontal = { location = "rightbelow", split_ratio = 0.3 },
vertical = { location = "rightbelow", split_ratio = 0.5 },
},
},
behavior = {
close_on_exit = true,
auto_insert = true,
},
enable_new_mappings = true,
}
options = require("core.utils").load_override(options, "NvChad/nvterm")
nvterm.setup(options)

View File

@ -1,18 +1,48 @@
local M = {} local M = {}
local load_override = require("core.utils").load_override
local utils = require "core.utils" local utils = require "core.utils"
M.blankline = { M.autopairs = function()
local present1, autopairs = pcall(require, "nvim-autopairs")
local present2, cmp = pcall(require, "cmp")
if not (present1 and present2) then
return
end
local options = {
fast_wrap = {},
disable_filetype = { "TelescopePrompt", "vim" },
}
options = load_override(options, "windwp/nvim-autopairs")
autopairs.setup(options)
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end
M.blankline = function()
local present, blankline = pcall(require, "indent_blankline")
if not present then
return
end
require("base46").load_highlight "blankline"
local options = {
indentLine_enabled = 1, indentLine_enabled = 1,
filetype_exclude = { filetype_exclude = {
"help", "help",
"terminal", "terminal",
"lazy", "alpha",
"packer",
"lspinfo", "lspinfo",
"TelescopePrompt", "TelescopePrompt",
"TelescopeResults", "TelescopeResults",
"mason", "mason",
"nvdash",
"nvcheatsheet",
"", "",
}, },
buftype_exclude = { "terminal" }, buftype_exclude = { "terminal" },
@ -20,22 +50,72 @@ M.blankline = {
show_first_indent_level = false, show_first_indent_level = false,
show_current_context = true, show_current_context = true,
show_current_context_start = true, show_current_context_start = true,
} }
M.luasnip = function(opts) options = load_override(options, "lukas-reineke/indent-blankline.nvim")
require("luasnip").config.set_config(opts) blankline.setup(options)
end
-- vscode format M.colorizer = function()
local present, colorizer = pcall(require, "colorizer")
if not present then
return
end
local options = {
filetypes = {
"*",
},
user_default_options = {
RGB = true, -- #RGB hex codes
RRGGBB = true, -- #RRGGBB hex codes
names = false, -- "Name" codes like Blue
RRGGBBAA = false, -- #RRGGBBAA hex codes
rgb_fn = false, -- CSS rgb() and rgba() functions
hsl_fn = false, -- CSS hsl() and hsla() functions
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = "background", -- Set the display mode.
},
}
options = load_override(options, "NvChad/nvim-colorizer.lua")
colorizer.setup(options)
-- execute colorizer as soon as possible
vim.defer_fn(function()
require("colorizer").attach_to_buffer(0)
end, 0)
end
M.comment = function()
local present, nvim_comment = pcall(require, "Comment")
if not present then
return
end
local options = {}
options = load_override(options, "numToStr/Comment.nvim")
nvim_comment.setup(options)
end
M.luasnip = function()
local present, luasnip = pcall(require, "luasnip")
if not present then
return
end
local options = {
history = true,
updateevents = "TextChanged,TextChangedI",
}
options = load_override(options, "L3MON4D3/LuaSnip")
luasnip.config.set_config(options)
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" }
-- snipmate format
require("luasnip.loaders.from_snipmate").load()
require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" }
-- lua format
require("luasnip.loaders.from_lua").load()
require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" }
vim.api.nvim_create_autocmd("InsertLeave", { vim.api.nvim_create_autocmd("InsertLeave", {
callback = function() callback = function()
@ -49,18 +129,61 @@ M.luasnip = function(opts)
}) })
end end
M.gitsigns = { M.gitsigns = function()
local present, gitsigns = pcall(require, "gitsigns")
if not present then
return
end
require("base46").load_highlight "git"
local options = {
signs = { signs = {
add = { text = "" }, add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" },
change = { text = "" }, change = { hl = "DiffChange", text = "", numhl = "GitSignsChangeNr" },
delete = { text = "󰍵" }, delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
topdelete = { text = "" }, topdelete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
changedelete = { text = "~" }, changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
untracked = { text = "" },
}, },
on_attach = function(bufnr) on_attach = function (bufnr)
utils.load_mappings("gitsigns", { buffer = bufnr }) utils.load_mappings("gitsigns", { buffer = bufnr })
end
}
options = load_override(options, "lewis6991/gitsigns.nvim")
gitsigns.setup(options)
end
M.devicons = function()
local present, devicons = pcall(require, "nvim-web-devicons")
if present then
require("base46").load_highlight "devicons"
local options = { override = require("nvchad_ui.icons").devicons }
options = require("core.utils").load_override(options, "nvim-tree/nvim-web-devicons")
devicons.setup(options)
end
end
M.packer_init = function()
return {
auto_clean = true,
compile_on_sync = true,
git = { clone_timeout = 6000 },
display = {
working_sym = "",
error_sym = "",
done_sym = "",
removed_sym = "",
moved_sym = "",
open_fn = function()
return require("packer.util").float { border = "single" }
end, end,
} },
}
end
return M return M

View File

@ -1,3 +1,13 @@
local present, telescope = pcall(require, "telescope")
if not present then
return
end
vim.g.theme_switcher_loaded = true
require("base46").load_highlight "telescope"
local options = { local options = {
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {
@ -52,4 +62,13 @@ local options = {
extensions_list = { "themes", "terms" }, extensions_list = { "themes", "terms" },
} }
return options -- check for any override
options = require("core.utils").load_override(options, "nvim-telescope/telescope.nvim")
telescope.setup(options)
-- load extensions
pcall(function()
for _, ext in ipairs(options.extensions_list) do
telescope.load_extension(ext)
end
end)

View File

@ -1,12 +1,27 @@
local present, treesitter = pcall(require, "nvim-treesitter.configs")
if not present then
return
end
require("base46").load_highlight "treesitter"
local options = { local options = {
ensure_installed = { "lua" }, ensure_installed = {
"lua",
},
highlight = { highlight = {
enable = true, enable = true,
use_languagetree = true, use_languagetree = true,
}, },
indent = { enable = true }, indent = {
enable = true,
},
} }
return options -- check for any override
options = require("core.utils").load_override(options, "nvim-treesitter/nvim-treesitter")
treesitter.setup(options)

View File

@ -0,0 +1,41 @@
local present, wk = pcall(require, "which-key")
if not present then
return
end
require("base46").load_highlight "whichkey"
local options = {
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+", -- symbol prepended to a group
},
popup_mappings = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
window = {
border = "none", -- none/single/double/shadow
},
layout = {
spacing = 6, -- spacing between columns
},
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " },
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
i = { "j", "k" },
v = { "j", "k" },
},
}
options = require("core.utils").load_override(options, "folke/which-key.nvim")
wk.setup(options)

View File

@ -1,144 +1,116 @@
-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false local plugins = {
-- List of all default plugins & their definitions
local default_plugins = {
"nvim-lua/plenary.nvim", ["nvim-lua/plenary.nvim"] = { module = "plenary" },
{ ["lewis6991/impatient.nvim"] = {},
"NvChad/base46",
branch = "v2.0", ["wbthomason/packer.nvim"] = {
build = function() cmd = require("core.lazy_load").packer_cmds,
require("base46").load_all_highlights() config = function()
require "plugins"
end, end,
}, },
{ ["NvChad/extensions"] = { branch = "main", module = { "telescope", "nvchad" } },
"NvChad/ui",
branch = "v2.0", ["NvChad/base46"] = {
lazy = false, branch = "master",
config = function()
local ok, base46 = pcall(require, "base46")
if ok then
base46.load_theme()
end
end,
}, },
{ ["NvChad/ui"] = {
"NvChad/nvterm", branch = "main",
init = function() after = "base46",
config = function()
local present, nvchad_ui = pcall(require, "nvchad_ui")
if present then
nvchad_ui.setup()
end
end,
},
["NvChad/nvterm"] = {
module = "nvterm",
config = function()
require "plugins.configs.nvterm"
end,
setup = function()
require("core.utils").load_mappings "nvterm" require("core.utils").load_mappings "nvterm"
end, end,
config = function(_, opts) },
require "base46.term"
require("nvterm").setup(opts) ["nvim-tree/nvim-web-devicons"] = {
after = "ui",
module = "nvim-web-devicons",
commit = "dd468f6991a4e447607097dfc89d47ae97d14dea",
config = function()
require("plugins.configs.others").devicons()
end, end,
}, },
{ ["lukas-reineke/indent-blankline.nvim"] = {
"NvChad/nvim-colorizer.lua", opt = true,
init = function() setup = function()
require("core.utils").lazy_load "nvim-colorizer.lua" require("core.lazy_load").on_file_open "indent-blankline.nvim"
end,
config = function(_, opts)
require("colorizer").setup(opts)
-- execute colorizer as soon as possible
vim.defer_fn(function()
require("colorizer").attach_to_buffer(0)
end, 0)
end,
},
{
"nvim-tree/nvim-web-devicons",
opts = function()
return { override = require "nvchad.icons.devicons" }
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "devicons")
require("nvim-web-devicons").setup(opts)
end,
},
{
"lukas-reineke/indent-blankline.nvim",
version = "2.20.7",
init = function()
require("core.utils").lazy_load "indent-blankline.nvim"
end,
opts = function()
return require("plugins.configs.others").blankline
end,
config = function(_, opts)
require("core.utils").load_mappings "blankline" require("core.utils").load_mappings "blankline"
dofile(vim.g.base46_cache .. "blankline") end,
require("indent_blankline").setup(opts) config = function()
require("plugins.configs.others").blankline()
end, end,
}, },
{ ["NvChad/nvim-colorizer.lua"] = {
"nvim-treesitter/nvim-treesitter", opt = true,
init = function() setup = function()
require("core.utils").lazy_load "nvim-treesitter" require("core.lazy_load").on_file_open "nvim-colorizer.lua"
end, end,
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, config = function()
build = ":TSUpdate", require("plugins.configs.others").colorizer()
opts = function()
return require "plugins.configs.treesitter"
end, end,
config = function(_, opts) },
dofile(vim.g.base46_cache .. "syntax")
require("nvim-treesitter.configs").setup(opts) ["nvim-treesitter/nvim-treesitter"] = {
module = "nvim-treesitter",
setup = function()
require("core.lazy_load").on_file_open "nvim-treesitter"
end,
cmd = require("core.lazy_load").treesitter_cmds,
run = ":TSUpdate",
config = function()
require "plugins.configs.treesitter"
end, end,
}, },
-- git stuff -- git stuff
{ ["lewis6991/gitsigns.nvim"] = {
"lewis6991/gitsigns.nvim", ft = "gitcommit",
ft = { "gitcommit", "diff" }, setup = function()
init = function() require("core.lazy_load").gitsigns()
-- load gitsigns only when a git file is opened
vim.api.nvim_create_autocmd({ "BufRead" }, {
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
callback = function()
vim.fn.system("git -C " .. '"' .. vim.fn.expand "%:p:h" .. '"' .. " rev-parse")
if vim.v.shell_error == 0 then
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
vim.schedule(function()
require("lazy").load { plugins = { "gitsigns.nvim" } }
end)
end
end, end,
}) config = function()
end, require("plugins.configs.others").gitsigns()
opts = function()
return require("plugins.configs.others").gitsigns
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "git")
require("gitsigns").setup(opts)
end, end,
}, },
-- lsp stuff -- lsp stuff
{ ["williamboman/mason.nvim"] = {
"williamboman/mason.nvim", cmd = require("core.lazy_load").mason_cmds,
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, config = function()
opts = function() require "plugins.configs.mason"
return require "plugins.configs.mason"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "mason")
require("mason").setup(opts)
-- custom nvchad cmd to install all mason binaries listed
vim.api.nvim_create_user_command("MasonInstallAll", function()
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
end, {})
vim.g.mason_binaries_list = opts.ensure_installed
end, end,
}, },
{ ["neovim/nvim-lspconfig"] = {
"neovim/nvim-lspconfig", opt = true,
init = function() setup = function()
require("core.utils").lazy_load "nvim-lspconfig" require("core.lazy_load").on_file_open "nvim-lspconfig"
end, end,
config = function() config = function()
require "plugins.configs.lspconfig" require "plugins.configs.lspconfig"
@ -146,127 +118,109 @@ local default_plugins = {
}, },
-- load luasnips + cmp related in insert mode only -- load luasnips + cmp related in insert mode only
{
"hrsh7th/nvim-cmp", ["rafamadriz/friendly-snippets"] = {
module = { "cmp", "cmp_nvim_lsp" },
event = "InsertEnter", event = "InsertEnter",
dependencies = { },
{
-- snippet plugin ["hrsh7th/nvim-cmp"] = {
"L3MON4D3/LuaSnip", after = "friendly-snippets",
dependencies = "rafamadriz/friendly-snippets", config = function()
opts = { history = true, updateevents = "TextChanged,TextChangedI" }, require "plugins.configs.cmp"
config = function(_, opts)
require("plugins.configs.others").luasnip(opts)
end, end,
}, },
-- autopairing of (){}[] etc ["L3MON4D3/LuaSnip"] = {
{ wants = "friendly-snippets",
"windwp/nvim-autopairs", after = "nvim-cmp",
opts = { config = function()
fast_wrap = {}, require("plugins.configs.others").luasnip()
disable_filetype = { "TelescopePrompt", "vim" },
},
config = function(_, opts)
require("nvim-autopairs").setup(opts)
-- setup cmp for autopairs
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
end, end,
}, },
-- cmp sources plugins ["saadparwaiz1/cmp_luasnip"] = { after = "LuaSnip" },
{ ["hrsh7th/cmp-nvim-lua"] = { after = "cmp_luasnip" },
"saadparwaiz1/cmp_luasnip", ["hrsh7th/cmp-nvim-lsp"] = { after = "cmp-nvim-lua" },
"hrsh7th/cmp-nvim-lua", ["hrsh7th/cmp-buffer"] = { after = "cmp-nvim-lsp" },
"hrsh7th/cmp-nvim-lsp", ["hrsh7th/cmp-path"] = { after = "cmp-buffer" },
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path", -- misc plugins
}, ["windwp/nvim-autopairs"] = {
}, after = "nvim-cmp",
opts = function() config = function()
return require "plugins.configs.cmp" require("plugins.configs.others").autopairs()
end,
config = function(_, opts)
require("cmp").setup(opts)
end, end,
}, },
{ ["goolord/alpha-nvim"] = {
"numToStr/Comment.nvim", after = "base46",
keys = { disable = true,
{ "gcc", mode = "n", desc = "Comment toggle current line" }, config = function()
{ "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, require "plugins.configs.alpha"
{ "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, end,
{ "gbc", mode = "n", desc = "Comment toggle current block" },
{ "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" },
{ "gb", mode = "x", desc = "Comment toggle blockwise (visual)" },
}, },
init = function()
["numToStr/Comment.nvim"] = {
module = "Comment",
keys = { "gc", "gb" },
config = function()
require("plugins.configs.others").comment()
end,
setup = function()
require("core.utils").load_mappings "comment" require("core.utils").load_mappings "comment"
end, end,
config = function(_, opts)
require("Comment").setup(opts)
end,
}, },
-- file managing , picker etc -- file managing , picker etc
{ ["nvim-tree/nvim-tree.lua"] = {
"nvim-tree/nvim-tree.lua", ft = "alpha",
cmd = { "NvimTreeToggle", "NvimTreeFocus" }, cmd = { "NvimTreeToggle", "NvimTreeFocus" },
init = function() config = function()
require "plugins.configs.nvimtree"
end,
setup = function()
require("core.utils").load_mappings "nvimtree" require("core.utils").load_mappings "nvimtree"
end, end,
opts = function()
return require "plugins.configs.nvimtree"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "nvimtree")
require("nvim-tree").setup(opts)
end,
}, },
{ ["nvim-telescope/telescope.nvim"] = {
"nvim-telescope/telescope.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
cmd = "Telescope", cmd = "Telescope",
init = function() config = function()
require "plugins.configs.telescope"
end,
setup = function()
require("core.utils").load_mappings "telescope" require("core.utils").load_mappings "telescope"
end, end,
opts = function()
return require "plugins.configs.telescope"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "telescope")
local telescope = require "telescope"
telescope.setup(opts)
-- load extensions
for _, ext in ipairs(opts.extensions_list) do
telescope.load_extension(ext)
end
end,
}, },
-- Only load whichkey after all the gui -- Only load whichkey after all the gui
{ ["folke/which-key.nvim"] = {
"folke/which-key.nvim", disable = true,
keys = { "<leader>", '"', "'", "`", "c", "v", "g" }, module = "which-key",
init = function() keys = { "<leader>", '"', "'", "`" },
require("core.utils").load_mappings "whichkey" config = function()
require "plugins.configs.whichkey"
end, end,
config = function(_, opts) setup = function()
dofile(vim.g.base46_cache .. "whichkey") require("core.utils").load_mappings "whichkey"
require("which-key").setup(opts)
end, end,
}, },
} }
local config = require("core.utils").load_config() -- Load all plugins
local present, packer = pcall(require, "packer")
if #config.plugins > 0 then if present then
table.insert(default_plugins, { import = config.plugins }) vim.cmd "packadd packer.nvim"
-- Override with default plugins with user ones
plugins = require("core.utils").merge_plugins(plugins)
-- load packer init options
local init_options = require("plugins.configs.others").packer_init()
init_options = require("core.utils").load_override(init_options, "wbthomason/packer.nvim")
packer.init(init_options)
packer.startup { plugins }
end end
require("lazy").setup(default_plugins, config.lazy_nvim)