From fb4b0a7261bcfc97d1305e919d021c33454a748f Mon Sep 17 00:00:00 2001 From: Adam Bellinson Date: Sat, 16 Dec 2023 23:48:41 -0500 Subject: [PATCH] HELLO NvChad --- .gitignore | 2 +- lua/custom/README.md | 3 + lua/custom/chadrc.lua | 20 ++++ lua/custom/configs/lspconfig.lua | 30 ++++++ lua/custom/configs/null-ls.lua | 21 +++++ lua/custom/configs/overrides.lua | 67 ++++++++++++++ lua/custom/configs/rust-tools.lua | 13 +++ lua/custom/highlights.lua | 19 ++++ lua/custom/init.lua | 11 +++ lua/custom/mappings.lua | 67 ++++++++++++++ lua/custom/plugins.lua | 146 ++++++++++++++++++++++++++++++ 11 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 lua/custom/README.md create mode 100644 lua/custom/chadrc.lua create mode 100644 lua/custom/configs/lspconfig.lua create mode 100644 lua/custom/configs/null-ls.lua create mode 100644 lua/custom/configs/overrides.lua create mode 100644 lua/custom/configs/rust-tools.lua create mode 100644 lua/custom/highlights.lua create mode 100644 lua/custom/init.lua create mode 100644 lua/custom/mappings.lua create mode 100644 lua/custom/plugins.lua diff --git a/.gitignore b/.gitignore index d8a93d9..83eb95c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ plugin -custom +# custom spell ftplugin syntax diff --git a/lua/custom/README.md b/lua/custom/README.md new file mode 100644 index 0000000..0cc616c --- /dev/null +++ b/lua/custom/README.md @@ -0,0 +1,3 @@ +# Example_config + +This can be used as an example custom config for NvChad. Do check the https://github.com/NvChad/nvcommunity diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua new file mode 100644 index 0000000..14bb152 --- /dev/null +++ b/lua/custom/chadrc.lua @@ -0,0 +1,20 @@ +---@type ChadrcConfig +local M = {} + +-- Path to overriding theme and highlights files +local highlights = require "custom.highlights" + +M.ui = { + theme = "ashes", + theme_toggle = { "ashes", "one_light" }, + + hl_override = highlights.override, + hl_add = highlights.add, +} + +M.plugins = "custom.plugins" + +-- check core.mappings for table structure +M.mappings = require "custom.mappings" + +return M diff --git a/lua/custom/configs/lspconfig.lua b/lua/custom/configs/lspconfig.lua new file mode 100644 index 0000000..5666541 --- /dev/null +++ b/lua/custom/configs/lspconfig.lua @@ -0,0 +1,30 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities +local lspconfig = require "lspconfig" +-- local util = require "lspconfig/util" + +-- if you just want default config for the servers then put them in a table +local servers = { "html", "cssls", "tsserver", "clangd" } + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +-- lspconfig.rust_analyzer.setup({ +-- on_attach = on_attach, +-- capabilities = capabilities, +-- filetypes = {"rust"}, +-- root_dir = util.root_pattern("Cargo.toml"), +-- settings = {}, +-- ['rust-analyzer'] = { +-- cargo = { +-- allFeatures = true, +-- } +-- } +-- }) + +-- +-- lspconfig.pyright.setup { blabla} diff --git a/lua/custom/configs/null-ls.lua b/lua/custom/configs/null-ls.lua new file mode 100644 index 0000000..99cdbf1 --- /dev/null +++ b/lua/custom/configs/null-ls.lua @@ -0,0 +1,21 @@ +local null_ls = require "null-ls" + +local b = null_ls.builtins + +local sources = { + + -- webdev stuff + b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast! + b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes + + -- Lua + b.formatting.stylua, + + -- cpp + b.formatting.clang_format, +} + +null_ls.setup { + debug = true, + sources = sources, +} diff --git a/lua/custom/configs/overrides.lua b/lua/custom/configs/overrides.lua new file mode 100644 index 0000000..6f2729e --- /dev/null +++ b/lua/custom/configs/overrides.lua @@ -0,0 +1,67 @@ +local cmp = require "cmp" + +local M = {} + +M.treesitter = { + ensure_installed = { + "vim", + "lua", + "html", + "css", + "javascript", + "typescript", + "tsx", + "c", + "markdown", + "markdown_inline", + }, + indent = { + enable = true, + -- disable = { + -- "python" + -- }, + }, +} + +M.mason = { + ensure_installed = { + -- lua stuff + "lua-language-server", + "stylua", + + -- web dev stuff + "css-lsp", + "html-lsp", + "typescript-language-server", + "deno", + "prettier", + + -- c/cpp stuff + "clangd", + "clang-format", + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +-- M.cmp = { +-- mapping = { +-- [""] = cmp.mapping.complete(), +-- } +-- } + +return M diff --git a/lua/custom/configs/rust-tools.lua b/lua/custom/configs/rust-tools.lua new file mode 100644 index 0000000..490e1a0 --- /dev/null +++ b/lua/custom/configs/rust-tools.lua @@ -0,0 +1,13 @@ +-- local on_attach = require("plugins.configs.lspconfig").on_attach +-- local capabilities = require("plugins.configs.lspconfig").capabilities +-- +-- local options = { +-- server = { +-- on_attach = vim.tbl_deep_extend("force", on_attach, { +-- vim.keymap.set("n", "H", rt) +-- }, +-- capabilities = capabilities, +-- }, +-- } +-- +-- return options diff --git a/lua/custom/highlights.lua b/lua/custom/highlights.lua new file mode 100644 index 0000000..ebf2dfb --- /dev/null +++ b/lua/custom/highlights.lua @@ -0,0 +1,19 @@ +-- To find any highlight groups: " Telescope highlights" +-- Each highlight group can take a table with variables fg, bg, bold, italic, etc +-- base30 variable names can also be used as colors + +local M = {} + +---@type Base46HLGroupsList +M.override = { + Comment = { + italic = true, + }, +} + +---@type HLTable +M.add = { + NvimTreeOpenedFolderName = { fg = "green", bold = true }, +} + +return M diff --git a/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 0000000..d44d34e --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1,11 @@ +-- local autocmd = vim.api.nvim_create_autocmd + +-- Auto resize panes when resizing nvim window +-- autocmd("VimResized", { +-- pattern = "*", +-- command = "tabdo wincmd =", +-- }) +-- +local opt = vim.opt + +opt.laststatus = 3 diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua new file mode 100644 index 0000000..688234f --- /dev/null +++ b/lua/custom/mappings.lua @@ -0,0 +1,67 @@ +---@type MappingsTable +local M = {} + +M.general = { + i = { + [""] = { "", "paste from OS without autopairing" }, + }, + n = { + -- [";"] = { ":", "enter command mode", opts = { nowait = true } }, + ["go"] = { + function() + vim.lsp.buf.format { async = true } + end, + "LSP formatting", + }, + + ["wv"] = { "v", "Split vertical" }, + ["ws"] = { "s", "Split horizontal" }, + ["wo"] = { "o", "Maximize split" }, + ["wc"] = { "c", "Close split" }, + ["w="] = { "w=", "Even splits" }, + ["h"] = { "h", "Focus left split" }, + ["j"] = { "j", "Focus lower split" }, + ["k"] = { "k", "Focus upper split" }, + ["l"] = { "l", "Focus right split" }, + ["ee"] = { ':e =expand("%:p:h" . "/" )', "Copy relative path to file" }, + ["er"] = { ":!echo -n % | pbcopy", "Copy absolute path to file" }, + ["gn"] = { ":Telescope resume", "Resume telescope" }, + ["eu"] = { '!!python -c "import uuid; print(uuid.uuid4())"', "Drop fresh uuid4" }, + [""] = { '"+y', "Copy to OS clipboard" }, + + [",,"] = { ":w", "save" }, + [" "] = { ":w", "save" }, + + [",z"] = { ":bnext", "Next buffer" }, + [",v"] = { ":bprevious", "Previous buffer" }, + ["z"] = { ":bnext", "Next buffer" }, + ["v"] = { ":bprevious", "Previous buffer" }, + + ["n"] = { " NvimTreeToggle ", "Toggle nvimtree" }, + ["N"] = { " set nu! ", "Toggle line number" }, + + ["c"] = { "bdelete", "Close Buffer" }, + ["b"] = { " Telescope buffers ", "Find buffers" }, + + -- [""] = cmp.mapping.complete(), + }, + v = { + [">"] = { ">gv", "indent" }, + [""] = { '"+y', "Copy to OS clipboard" }, + }, +} + +M.crates = { + n = { + ["rcu"] = { + function() + require("crates").upgrade_all_crates() + end, + "Update crates", + }, + }, +} + +-- more keybinds! + +return M diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua new file mode 100644 index 0000000..4cd97e0 --- /dev/null +++ b/lua/custom/plugins.lua @@ -0,0 +1,146 @@ +local overrides = require "custom.configs.overrides" + +---@type NvPluginSpec[] +local plugins = { + + -- Override plugin definition options + + { + "neovim/nvim-lspconfig", + dependencies = { + -- format & linting + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require "custom.configs.null-ls" + end, + }, + }, + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, -- Override to setup mason-lspconfig + }, + + -- override plugin configs + { + "williamboman/mason.nvim", + opts = vim.tbl_deep_extend("force", overrides.mason, { + ensure_installed = { + "rust-analyzer", + }, + }), + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + + { + "nvim-tree/nvim-tree.lua", + opts = overrides.nvimtree, + }, + + -- Install a plugin + { + "max397574/better-escape.nvim", + event = "InsertEnter", + config = function() + require("better_escape").setup() + end, + }, + + { + "elixir-tools/elixir-tools.nvim", + version = "*", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local elixir = require "elixir" + local elixirls = require "elixir.elixirls" + + elixir.setup { + nextls = { enable = true }, + credo = {}, + elixirls = { + enable = true, + settings = elixirls.settings { + dialyzerEnabled = false, + enableTestLenses = false, + }, + on_attach = function(client, bufnr) + vim.keymap.set("n", "fp", ":ElixirFromPipe", { buffer = true, noremap = true }) + vim.keymap.set("n", "tp", ":ElixirToPipe", { buffer = true, noremap = true }) + vim.keymap.set("v", "em", ":ElixirExpandMacro", { buffer = true, noremap = true }) + end, + }, + } + end, + dependencies = { + "nvim-lua/plenary.nvim", + }, + }, + + { + "rust-lang/rust.vim", + ft = "rust", + init = function() + vim.g.rustfmt_autosave = 1 + end, + }, + + { + "mrcjkb/rustaceanvim", + version = "^3", + 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", + dependencies = "hrsh7th/nvim-cmp", + 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 = "cartes" }) + return M + end, + }, + + { "tpope/vim-surround", lazy = false }, + + -- To make a plugin not be loaded + -- { + -- "NvChad/nvim-colorizer.lua", + -- enabled = false + -- }, + + -- All NvChad plugins are lazy-loaded by default + -- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false` + -- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example + -- { + -- "mg979/vim-visual-multi", + -- lazy = false, + -- } +} + +return plugins