From 72c72fbd104f5bf41ab6031500282d537c33f5f9 Mon Sep 17 00:00:00 2001 From: Alessandro Date: Mon, 2 Sep 2024 11:47:52 +0200 Subject: [PATCH] Add initial nvchad config --- install.conf.yaml | 2 + nvim/.stylua.toml | 6 +++ nvim/LICENSE | 24 ++++++++++++ nvim/README.md | 9 +++++ nvim/init.lua | 37 ++++++++++++++++++ nvim/lazy-lock.json | 35 +++++++++++++++++ nvim/lua/chadrc.lua | 39 +++++++++++++++++++ nvim/lua/configs/conform.lua | 15 ++++++++ nvim/lua/configs/default-lsp.lua | 24 ++++++++++++ nvim/lua/configs/default-ts.lua | 14 +++++++ nvim/lua/configs/lazy.lua | 47 +++++++++++++++++++++++ nvim/lua/configs/lspconfig.lua | 24 ++++++++++++ nvim/lua/configs/nvim-tree.lua | 9 +++++ nvim/lua/mappings.lua | 21 ++++++++++ nvim/lua/options.lua | 8 ++++ nvim/lua/plugins/crates.lua | 22 +++++++++++ nvim/lua/plugins/endhints.lua | 7 ++++ nvim/lua/plugins/init.lua | 36 +++++++++++++++++ nvim/lua/plugins/mason-tool-installer.lua | 7 ++++ nvim/lua/plugins/onedarker.lua | 19 +++++++++ nvim/lua/plugins/project.lua | 12 ++++++ nvim/lua/plugins/rustaceanvim.lua | 14 +++++++ 22 files changed, 431 insertions(+) create mode 100644 nvim/.stylua.toml create mode 100644 nvim/LICENSE create mode 100644 nvim/README.md create mode 100644 nvim/init.lua create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lua/chadrc.lua create mode 100644 nvim/lua/configs/conform.lua create mode 100644 nvim/lua/configs/default-lsp.lua create mode 100644 nvim/lua/configs/default-ts.lua create mode 100644 nvim/lua/configs/lazy.lua create mode 100644 nvim/lua/configs/lspconfig.lua create mode 100644 nvim/lua/configs/nvim-tree.lua create mode 100644 nvim/lua/mappings.lua create mode 100644 nvim/lua/options.lua create mode 100644 nvim/lua/plugins/crates.lua create mode 100644 nvim/lua/plugins/endhints.lua create mode 100644 nvim/lua/plugins/init.lua create mode 100644 nvim/lua/plugins/mason-tool-installer.lua create mode 100644 nvim/lua/plugins/onedarker.lua create mode 100644 nvim/lua/plugins/project.lua create mode 100644 nvim/lua/plugins/rustaceanvim.lua diff --git a/install.conf.yaml b/install.conf.yaml index 8f3f149..f476c23 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -8,6 +8,8 @@ ~/.config/lvim/config.lua: path: lvim/config.lua create: true + ~/.config/nvim: + path: nvim ~/.zshrc: ~/.oh-my-zsh: path: ohmyzsh diff --git a/nvim/.stylua.toml b/nvim/.stylua.toml new file mode 100644 index 0000000..ecb6dca --- /dev/null +++ b/nvim/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "None" diff --git a/nvim/LICENSE b/nvim/LICENSE new file mode 100644 index 0000000..fdddb29 --- /dev/null +++ b/nvim/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/nvim/README.md b/nvim/README.md new file mode 100644 index 0000000..dc0deaa --- /dev/null +++ b/nvim/README.md @@ -0,0 +1,9 @@ +**This repo is supposed to used as config by NvChad users!** + +- The main nvchad repo (NvChad/NvChad) is used as a plugin by this repo. +- So you just import its modules , like `require "nvchad.options" , require "nvchad.mappings"` +- So you can delete the .git from this repo ( when you clone it locally ) or fork it :) + +# Credits + +1) Lazyvim starter https://github.com/LazyVim/starter as nvchad's starter was inspired by Lazyvim's . It made a lot of things easier! diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..9400ef8 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,37 @@ +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.uv.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", + }, + + { import = "plugins" }, +}, lazy_config) + +-- load theme +dofile(vim.g.base46_cache .. "defaults") +dofile(vim.g.base46_cache .. "statusline") + +require "options" +require "nvchad.autocmds" + +vim.schedule(function() + require "mappings" +end) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..2aaa500 --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,35 @@ +{ + "LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" }, + "NvChad": { "branch": "v2.5", "commit": "b7a163e232524f1024a59a0a5c6ddf123530085c" }, + "auto-save.nvim": { "branch": "main", "commit": "979b6c82f60cfa80f4cf437d77446d0ded0addf0" }, + "base46": { "branch": "v2.5", "commit": "94957a0edf563d63e2ab28f5f21190d0f24e431a" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, + "crates.nvim": { "branch": "main", "commit": "1c924d5a9ea3496c4e1a02d0d51388ba809f8468" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "gitsigns.nvim": { "branch": "main", "commit": "899e993850084ea33d001ec229d237bc020c19ae" }, + "indent-blankline.nvim": { "branch": "master", "commit": "db926997af951da38e5004ec7b9fbdc480b48f5d" }, + "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "nvim-autopairs": { "branch": "master", "commit": "fd2badc24e675f947162a16c124d395bde80dbd6" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "194ec600488f7c7229668d0e80bd197f3a2b84ff" }, + "nvim-lsp-endhints": { "branch": "main", "commit": "4af226bd3fb235e623d4ffcc14372a3d9b75e40b" }, + "nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" }, + "nvim-tree.lua": { "branch": "master", "commit": "ea55ef12036897fdc4476b115a395d2a34965c82" }, + "nvim-treesitter": { "branch": "master", "commit": "a1573a9135c608e68cb383f752623527be84bdce" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, + "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "8f47c3d70286a85940cafe990a64b0eac1033671" }, + "rustaceanvim": { "branch": "master", "commit": "d3a8b145f0b3db4de9a08fcbc604659f52ee4fbc" }, + "telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" }, + "ui": { "branch": "v2.5", "commit": "cd474496cdc41c833f6376eaf20e7c357b7a2e35" }, + "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" } +} diff --git a/nvim/lua/chadrc.lua b/nvim/lua/chadrc.lua new file mode 100644 index 0000000..441f47c --- /dev/null +++ b/nvim/lua/chadrc.lua @@ -0,0 +1,39 @@ +-- This file needs to have same structure as nvconfig.lua +-- https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua + +---@type ChadrcConfig +local M = {} + +M.base46 = { + theme = "onedark", + + -- hl_override = { + -- Comment = { italic = true }, + -- ["@comment"] = { italic = true }, + -- }, +} + + +M.ui = { + statusline = { + theme = "vscode_colored", + }, + + nvdash = { + load_on_startup = true, + header = { + " ▄▄ ▄ ▄▄▄▄▄▄▄ ", + "▄▀███▄ ▄██ █████▀ ", + "██▄▀███▄ ███ ", + "███ ▀███▄ ███ ", + "███ ▀██ ███ ", + "███ ▀ ███ ", + "▀██ █████▄▀█▀▄██████▄ ", + " ▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ", + } + } +} + + + +return M diff --git a/nvim/lua/configs/conform.lua b/nvim/lua/configs/conform.lua new file mode 100644 index 0000000..35ba6cf --- /dev/null +++ b/nvim/lua/configs/conform.lua @@ -0,0 +1,15 @@ +local options = { + formatters_by_ft = { + lua = { "stylua" }, + -- css = { "prettier" }, + -- html = { "prettier" }, + }, + + -- format_on_save = { + -- -- These options will be passed to conform.format() + -- timeout_ms = 500, + -- lsp_fallback = true, + -- }, +} + +return options diff --git a/nvim/lua/configs/default-lsp.lua b/nvim/lua/configs/default-lsp.lua new file mode 100644 index 0000000..91aae08 --- /dev/null +++ b/nvim/lua/configs/default-lsp.lua @@ -0,0 +1,24 @@ +return { + ensure_installed = { + "lua-language-server", + "luacheck", + + "misspell", + + "shellcheck", + "shfmt", + "bash-language-server", + + "rust-analyzer", + "taplo", + + "jdtls", + + "clangd", + + "pyright", + "ruff", + + "dockerfile-language-server", + }, +} diff --git a/nvim/lua/configs/default-ts.lua b/nvim/lua/configs/default-ts.lua new file mode 100644 index 0000000..ce75384 --- /dev/null +++ b/nvim/lua/configs/default-ts.lua @@ -0,0 +1,14 @@ +return { + auto_install = true, + ensure_installed = { + "lua", + "rust", + "java", + "c", + "cpp", + "markdown", + "markdown_inline", + "comment", + "toml", + }, +} diff --git a/nvim/lua/configs/lazy.lua b/nvim/lua/configs/lazy.lua new file mode 100644 index 0000000..cd170bd --- /dev/null +++ b/nvim/lua/configs/lazy.lua @@ -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", + }, + }, + }, +} diff --git a/nvim/lua/configs/lspconfig.lua b/nvim/lua/configs/lspconfig.lua new file mode 100644 index 0000000..935311d --- /dev/null +++ b/nvim/lua/configs/lspconfig.lua @@ -0,0 +1,24 @@ +-- load defaults i.e lua_lsp +require("nvchad.configs.lspconfig").defaults() + +local lspconfig = require "lspconfig" + +-- EXAMPLE +local servers = { "html", "cssls" } +local nvlsp = require "nvchad.configs.lspconfig" + +-- lsps with default config +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = nvlsp.on_attach, + on_init = nvlsp.on_init, + capabilities = nvlsp.capabilities, + } +end + +-- configuring single server, example: typescript +-- lspconfig.tsserver.setup { +-- on_attach = nvlsp.on_attach, +-- on_init = nvlsp.on_init, +-- capabilities = nvlsp.capabilities, +-- } diff --git a/nvim/lua/configs/nvim-tree.lua b/nvim/lua/configs/nvim-tree.lua new file mode 100644 index 0000000..bd233e1 --- /dev/null +++ b/nvim/lua/configs/nvim-tree.lua @@ -0,0 +1,9 @@ +return { + renderer = { + icons = { + show = { + git = false, + }, + }, + }, +} diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua new file mode 100644 index 0000000..63f1f36 --- /dev/null +++ b/nvim/lua/mappings.lua @@ -0,0 +1,21 @@ +require "nvchad.mappings" + +-- add yours here + +local map = vim.keymap.set + +map("n", ";", ":", { desc = "CMD enter command mode" }) +map("i", "jk", "") +-- Group names +map("n", "d", "", { desc = "test" }) + +-- General +map("n", "q", "confirm q", { desc = "test" }) + +-- Lsp +map( + "n", + "lf", + " lua require('conform').format { lsp_fallback = true }", + { desc = "General Format file" } +) diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua new file mode 100644 index 0000000..81a6dc8 --- /dev/null +++ b/nvim/lua/options.lua @@ -0,0 +1,8 @@ +require "nvchad.options" + +-- add yours here! + +-- local o = vim.o +-- o.cursorlineopt ='both' -- to enable cursorline! + +vim.lsp.inlay_hint.enable(true) diff --git a/nvim/lua/plugins/crates.lua b/nvim/lua/plugins/crates.lua new file mode 100644 index 0000000..2faf12c --- /dev/null +++ b/nvim/lua/plugins/crates.lua @@ -0,0 +1,22 @@ +return { + "saecki/crates.nvim", + tag = "stable", + event = { "BufRead Cargo.toml" }, + config = function() + require("crates").setup{ + lsp = { + enabled = true, + actions = true, + completion = true, + hover = true, + }, + completion = { + crates = { + enabled = true, + max_results = 10, + min_chars = 3, + }, + } + } + end, +} diff --git a/nvim/lua/plugins/endhints.lua b/nvim/lua/plugins/endhints.lua new file mode 100644 index 0000000..1680d70 --- /dev/null +++ b/nvim/lua/plugins/endhints.lua @@ -0,0 +1,7 @@ +return { + "chrisgrieser/nvim-lsp-endhints", + event = "LspAttach", + opts = {icons = { + type = "󱈤 ", + },},} + diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..d33c7f6 --- /dev/null +++ b/nvim/lua/plugins/init.lua @@ -0,0 +1,36 @@ +return { + { + "stevearc/conform.nvim", + -- event = 'BufWritePre', -- uncomment for format on save + opts = require "configs.conform", + }, + + -- These are some examples, uncomment them if you want to see them work! + { + "neovim/nvim-lspconfig", + config = function() + require "configs.lspconfig" + end, + }, + + { + "Pocco81/auto-save.nvim", + config = function() + require("auto-save").setup() + end, + lazy = false, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = require "configs.default-ts", + }, + { + "hiphish/rainbow-delimiters.nvim", + lazy = false, + }, + { + "nvim-tree/nvim-tree.lua", + opts = require "configs.nvim-tree", + }, +} diff --git a/nvim/lua/plugins/mason-tool-installer.lua b/nvim/lua/plugins/mason-tool-installer.lua new file mode 100644 index 0000000..bac8fbe --- /dev/null +++ b/nvim/lua/plugins/mason-tool-installer.lua @@ -0,0 +1,7 @@ +return { + "WhoIsSethDaniel/mason-tool-installer.nvim", + lazy = false, + config = function() + require("mason-tool-installer").setup(require "configs.default-lsp") + end, +} diff --git a/nvim/lua/plugins/onedarker.lua b/nvim/lua/plugins/onedarker.lua new file mode 100644 index 0000000..f7974a0 --- /dev/null +++ b/nvim/lua/plugins/onedarker.lua @@ -0,0 +1,19 @@ +return { + "navarasu/onedark.nvim", + lazy = false, + config = function() + require("onedark").setup { + style = "darker", -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light' + toggle_style_key = "ss", + transparent = false, -- Show/hide background + + code_style = { + comments = "italic", + keywords = "italic,", + functions = "bold", + strings = "none", + variables = "none", + }, + } + end, +} diff --git a/nvim/lua/plugins/project.lua b/nvim/lua/plugins/project.lua new file mode 100644 index 0000000..2ab1266 --- /dev/null +++ b/nvim/lua/plugins/project.lua @@ -0,0 +1,12 @@ +return { + "ahmedkhalf/project.nvim", + lazy = false, + config = function() + require("telescope").load_extension "projects" + require("project_nvim").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end, + } diff --git a/nvim/lua/plugins/rustaceanvim.lua b/nvim/lua/plugins/rustaceanvim.lua new file mode 100644 index 0000000..0007a8a --- /dev/null +++ b/nvim/lua/plugins/rustaceanvim.lua @@ -0,0 +1,14 @@ +return { + "mrcjkb/rustaceanvim", + version = "^5", -- Recommended + lazy = false, -- This plugin is already lazy + config = function() + vim.g.rustaceanvim = { + tools = { + float_win_config = { + border = "rounded", + }, + }, + } + end, +}