diff --git a/.config/nvim/.stylua.toml b/.config/nvim/.stylua.toml new file mode 100644 index 0000000..ecb6dca --- /dev/null +++ b/.config/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/.config/nvim/LICENSE b/.config/nvim/LICENSE new file mode 100644 index 0000000..fdddb29 --- /dev/null +++ b/.config/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/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..8e0b381 --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1 @@ +## My NVChad neovim configuration, mainly for rust diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..0fda20c --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,37 @@ +vim.g.base46_cache = vim.fn.stdpath "data" .. "/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/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..62002f3 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,36 @@ +{ + "LuaSnip": { "branch": "master", "commit": "eda5be8f0ce9816278671f0b578cdbb8b762c701" }, + "NvChad": { "branch": "v2.5", "commit": "a792fd1d96c1511a165b18911164baa28bf1d6f4" }, + "base46": { "branch": "v2.5", "commit": "fde7a2cd54599e148d376f82980407c2d24b0fa2" }, + "cmp-async-path": { "branch": "main", "commit": "0ed1492f59e730c366d261a5ad822fa37e44c325" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, + "crates.nvim": { "branch": "main", "commit": "5d8b1bef686db0fabe5f1bb593744b617e8f1405" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "362fe61f9f19e9bceff178792780df5cce118a7d" }, + "image.nvim": { "branch": "master", "commit": "4c51d6202628b3b51e368152c053c3fb5c5f76f2" }, + "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, + "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-dap": { "branch": "master", "commit": "1c75a797b4017fec6491f509cf196c8c8833f26f" }, + "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-lspconfig": { "branch": "master", "commit": "bb3fb99cf14daa33014331ac6eb4b5de9180f775" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, + "rustaceanvim": { "branch": "master", "commit": "322224d00a731d75eed6b700d38e460fd30f6e3c" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "ui": { "branch": "v3.0", "commit": "ec5b1f8e591b2e8f1cd3653b41bb14d9cd43dfd1" }, + "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/.config/nvim/lua/chadrc.lua b/.config/nvim/lua/chadrc.lua new file mode 100644 index 0000000..7954d59 --- /dev/null +++ b/.config/nvim/lua/chadrc.lua @@ -0,0 +1,17 @@ +-- This file needs to have same structure as nvconfig.lua +-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua +-- Please read that file to know all available options :( + +---@type ChadrcConfig +local M = {} + +M.base46 = { + theme = "flex-light", + + -- hl_override = { + -- Comment = { italic = true }, + -- ["@comment"] = { italic = true }, + -- }, +} + +return M diff --git a/.config/nvim/lua/configs/conform.lua b/.config/nvim/lua/configs/conform.lua new file mode 100644 index 0000000..35ba6cf --- /dev/null +++ b/.config/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/.config/nvim/lua/configs/dap.lua b/.config/nvim/lua/configs/dap.lua new file mode 100644 index 0000000..99a34f6 --- /dev/null +++ b/.config/nvim/lua/configs/dap.lua @@ -0,0 +1,52 @@ +local dap = require("dap") +local dapui = require("dapui") + +-- Setup dap-ui +dapui.setup() + +-- Auto-open UI on DAP start +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end + +-- Paths for Mason v2 codelldb adapter +local mason_path = vim.fn.stdpath("data") .. "/mason/packages/codelldb/extension" +local adapter_path = mason_path .. "/adapter/codelldb" +local liblldb_path = mason_path .. "/lldb/lib/liblldb.so" + +-- Register the DAP adapter +dap.adapters.codelldb = { + type = "server", + host = "127.0.0.1", + port = "${port}", + executable = { + command = adapter_path, + args = { "--port", "${port}" }, + }, +} + +-- Debug configuration for Rust +dap.configurations.rust = { + { + name = "Launch Rust", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input( + "Path to executable: ", + vim.fn.getcwd() .. "/target/debug/", + "file" + ) + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + runInTerminal = false, + }, +} diff --git a/.config/nvim/lua/configs/lazy.lua b/.config/nvim/lua/configs/lazy.lua new file mode 100644 index 0000000..cd170bd --- /dev/null +++ b/.config/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/.config/nvim/lua/configs/lspconfig.lua b/.config/nvim/lua/configs/lspconfig.lua new file mode 100644 index 0000000..53eb46b --- /dev/null +++ b/.config/nvim/lua/configs/lspconfig.lua @@ -0,0 +1,31 @@ +-- load defaults i.e lua_lsp +require("nvchad.configs.lspconfig").defaults() + +local lspconfig = require "lspconfig" + +-- EXAMPLE +local servers = { + "html", + "cssls", + "clangd", + "pyright", + "zls", + "gopls", +} +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.ts_ls.setup { +-- on_attach = nvlsp.on_attach, +-- on_init = nvlsp.on_init, +-- capabilities = nvlsp.capabilities, +-- } diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..98ade45 --- /dev/null +++ b/.config/nvim/lua/mappings.lua @@ -0,0 +1,32 @@ +require "nvchad.mappings" + +-- add yours here + +local map = vim.keymap.set + +map("n", ";", ":", { desc = "CMD enter command mode" }) +map("i", "jk", "") + +-- map({ "n", "i", "v" }, "", " w ") + +map('i', '', function () + vim.fn.feedkeys(vim.fn['copilot#Accept'](), '') +end, { desc = 'Copilot Accept', noremap = true, silent = true }) + +-- Nvim DAP +map("n", "dl", "lua require'dap'.step_into()", { desc = "Debugger step into" }) +map("n", "dj", "lua require'dap'.step_over()", { desc = "Debugger step over" }) +map("n", "dk", "lua require'dap'.step_out()", { desc = "Debugger step out" }) +map("n", "dc", "lua require'dap'.continue()", { desc = "Debugger continue" }) +map("n", "db", "lua require'dap'.toggle_breakpoint()", { desc = "Debugger toggle breakpoint" }) +map( + "n", + "dd", + "lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))", + { desc = "Debugger set conditional breakpoint" } +) +map("n", "de", "lua require'dap'.terminate()", { desc = "Debugger reset" }) +map("n", "dr", "lua require'dap'.run_last()", { desc = "Debugger run last" }) + +-- rustaceanvim +map("n", "dt", "lua vim.cmd('RustLsp testables')", { desc = "Debugger testables" }) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua new file mode 100644 index 0000000..738f20b --- /dev/null +++ b/.config/nvim/lua/options.lua @@ -0,0 +1,6 @@ +require "nvchad.options" + +-- add yours here! + +-- local o = vim.o +-- o.cursorlineopt ='both' -- to enable cursorline! diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..1f9dbfd --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,106 @@ +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, + }, + + -- { + -- "github/copilot.vim", + -- lazy = false, + -- config = function() -- Mapping tab is already used in NvChad + -- vim.g.copilot_no_tab_map = true; -- Disable tab mapping + -- vim.g.copilot_assume_mapped = true; -- Assume that the mapping is already done + -- end + -- }, + + { + 'mrcjkb/rustaceanvim', + version = '^6', -- Recommended + lazy = false, -- This plugin is already lazy + ft = "rust", + config = function() + -- Option A: use executable directly + local codelldb_path = vim.fn.exepath("codelldb") + + -- Option B: manual path using $MASON + -- local mroot = vim.fn.expand("$MASON/packages/codelldb") + -- local codelldb_path = mroot .. "/extension/adapter/codelldb" + -- local liblldb_path = mroot .. "/extension/lldb/lib/liblldb.so" + + local cfg = require("rustaceanvim.config") + vim.g.rustaceanvim = { + dap = { + adapter = cfg.get_codelldb_adapter(codelldb_path), + }, + } + end + }, + + { + 'rust-lang/rust.vim', + ft = "rust", + init = function () + vim.g.rustfmt_autosave = 1 + end + }, + + { + 'mfussenegger/nvim-dap', + config = function() + require("configs.dap") + end, + }, + + { + 'rcarriga/nvim-dap-ui', + dependencies = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"}, + config = function() + require("dapui").setup() + end, + }, + + { + 'saecki/crates.nvim', + ft = {"toml"}, + config = function() + require("crates").setup { + completion = { + cmp = { + enabled = true + }, + }, + } + require('cmp').setup.buffer({ + sources = { { name = "crates" }} + }) + end + }, + + { + "3rd/image.nvim", + build = false, -- so that it doesn't build the rock https://github.com/3rd/image.nvim/issues/91#issuecomment-2453430239 + lazy = false, + opts = { + processor = "magick_cli", + } + }, + + -- { + -- "nvim-treesitter/nvim-treesitter", + -- opts = { + -- ensure_installed = { + -- "vim", "lua", "vimdoc", + -- "html", "css" + -- }, + -- }, + -- }, +}