diff options
| author | krolxon <krolyxon@tutanota.com> | 2026-01-07 23:05:50 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2026-01-07 23:05:50 +0530 |
| commit | 9e1bc68a323707c54fa16ff18a8b5bc0ed28c427 (patch) | |
| tree | c7b89e880a2ce7a40e21b7a62ed6e64f4977bc92 /.config/nvim/lua | |
| parent | 2e904234a732318e759272900a8a3383e1d3ac48 (diff) | |
add neovim configuration
Diffstat (limited to '.config/nvim/lua')
| -rw-r--r-- | .config/nvim/lua/config/autocmds.lua | 104 | ||||
| -rw-r--r-- | .config/nvim/lua/config/keymaps.lua | 14 | ||||
| -rw-r--r-- | .config/nvim/lua/config/lazy.lua | 53 | ||||
| -rw-r--r-- | .config/nvim/lua/config/options.lua | 15 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/colorscheme.lua | 12 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 26 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-tree.lua | 38 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/obsidian.lua | 54 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/platformio.lua | 6 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/snacks.lua | 8 |
10 files changed, 330 insertions, 0 deletions
diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..cdd5ac6 --- /dev/null +++ b/.config/nvim/lua/config/autocmds.lua @@ -0,0 +1,104 @@ +-- Autocmds are automatically loaded on the VeryLazy event +-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +-- +-- Add any additional autocmds here +-- with `vim.api.nvim_create_autocmd` +-- +-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults) +-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell") + +local autocmd = vim.api.nvim_create_autocmd + +-- remove trailing whitespaces on :w +autocmd({ "bufwritepre" }, { + pattern = "*", + command = [[%s/\s\+$//e]], +}) + +-- spell check markdown and tex files +vim.cmd([[ + augroup spellCheck + autocmd! + autocmd Filetype plaintext setlocal spell + autocmd FileType markdown setlocal spell + autocmd BufRead,BufNewFile *.md setlocal spell + autocmd BufRead,BufNewFile *.rmd setlocal spell + autocmd BufRead,BufNewFile *.Rmd setlocal spell + autocmd BufRead,BufNewFile *.tex setlocal spell + augroup END +]]) + +local build_commands = { + c = "!g++ -std=c++17 -o %:p:r.o %", + cpp = "!g++ -std=c++17 -Wall -O2 -o %:p:r.o %", + rust = "!cargo build --release", + go = "!go build", + -- tex = "pdflatex %", + tex = "VimtexCompile", + javascript = "", + java = "!jrun %", +} + +local debug_build_commands = { + c = "!g++ -std=c++17 -g -o %:p:r.o %", + cpp = "!g++ -std=c++17 -g -o %:p:r.o %", + rust = "!cargo build", + go = "!go build", +} + +local run_commands = { + c = "%:p:r.o", + cpp = "%:p:r.o", + rust = "cargo run --release", + go = "go run .", + tex = "", + javascript = "node %", + python = "python3 %", +} + +vim.api.nvim_create_user_command("Build", function() + local filetype = vim.bo.filetype + + for file, command in pairs(build_commands) do + if filetype == file then + vim.cmd(command) + break + end + end +end, {}) + +vim.api.nvim_create_user_command("DebugBuild", function() + local filetype = vim.bo.filetype + + for file, command in pairs(debug_build_commands) do + if filetype == file then + vim.cmd(command) + break + end + end +end, {}) + +vim.api.nvim_create_user_command("Run", function() + local filetype = vim.bo.filetype + + for file, command in pairs(run_commands) do + if filetype == file then + vim.cmd("sp") -- Vertical split + -- vim.cmd("vs") -- Horizontal split + vim.cmd("term " .. command) + vim.cmd("resize 20N") -- Comment this if horizontal + local keys = vim.api.nvim_replace_termcodes("i", true, false, true) + vim.api.nvim_feedkeys(keys, "n", false) + break + end + end +end, {}) + +vim.api.nvim_create_user_command("Ha", function() + vim.cmd([[Build]]) + vim.cmd([[Run]]) +end, {}) + +vim.api.nvim_create_user_command("Config", function() + vim.cmd([[cd ~/.config/nvim]]) +end, {}) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..ff7b0da --- /dev/null +++ b/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,14 @@ +-- Keymaps are automatically loaded on the VeryLazy event +-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Add any additional keymaps here +local map = vim.keymap.set +map("n", "<C-n>", "<cmd>NvimTreeToggle<Cr>", { desc = "NvimTree", remap = true }) + +-- Disable Ctrl+J in insert mode (make it do nothing) +vim.keymap.set("i", "<C-j>", "<Nop>", { noremap = true, silent = true }) + + +vim.keymap.set("n", "<Up>", "<c-w>k") +vim.keymap.set("n", "<Down>", "<c-w>j") +vim.keymap.set("n", "<Left>", "<c-w>h") +vim.keymap.set("n", "<Right>", "<c-w>l") diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..85dc8a3 --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,53 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { + -- add LazyVim and import its plugins + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + -- import/override with your plugins + { import = "plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, + -- have outdated releases, which may break your Neovim install. + version = false, -- always use the latest git commit + -- version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "tokyonight", "habamax" } }, + checker = { + enabled = true, -- check for plugin updates periodically + notify = false, -- notify on update + }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..4398c87 --- /dev/null +++ b/.config/nvim/lua/config/options.lua @@ -0,0 +1,15 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua +-- Add any additional options here + +vim.g.snacks_animate = false +vim.g.autoformat = false + +local opt = vim.opt +opt.relativenumber = true +opt.swapfile = false +opt.shiftwidth = 4 +opt.smartindent = true +opt.shiftround = false +opt.tabstop = 4 +opt.clipboard = "unnamedplus" diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..ebdab3a --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,12 @@ +return { + { + "folke/tokyonight.nvim", + opts = { + transparent = true, + styles = { + sidebars = "transparent", + floats = "transparent", + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..145182e --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,26 @@ +return { + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + -- Add your desired LSP server here + opts.servers.arduino_language_server = { + cmd = { + "arduino-language-server", + "-clangd", + "/usr/bin/clangd", + "-cli", + "/usr/bin/arduino-cli", + "-cli-config", + "/home/krolyxon/.arduino15/arduino-cli.yaml", + "-fqbn", + "arduino:avr:uno", + }, + } -- Example: Python + + opts.servers.pyright = {} + opts.servers.clangd = {} + + -- local servers = { "cssls", "jdtls", "slint_lsp", "pyright", "marksman", "eslint", "tailwindcss", "phpactor", "gopls", "clangd", "arduino_language_server" } + end, + }, +} diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..aa422bf --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,38 @@ +return { + "nvim-tree/nvim-tree.lua", + cmd = { "NvimTreeToggle", "NvimTreeFocus" }, + opts = { + filters = { dotfiles = false }, + disable_netrw = true, + hijack_cursor = true, + sync_root_with_cwd = true, + update_focused_file = { + enable = true, + update_root = false, + }, + view = { + width = 30, + preserve_window_proportions = true, + }, + renderer = { + root_folder_label = false, + highlight_git = true, + indent_markers = { enable = true }, + icons = { + glyphs = { + default = "", + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + }, + git = { unmerged = "" }, + }, + }, + }, + + } +} + diff --git a/.config/nvim/lua/plugins/obsidian.lua b/.config/nvim/lua/plugins/obsidian.lua new file mode 100644 index 0000000..bef0428 --- /dev/null +++ b/.config/nvim/lua/plugins/obsidian.lua @@ -0,0 +1,54 @@ +return { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = false, + -- ft = "markdown", + -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: + -- event = { + -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. + -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/*.md" + -- -- refer to `:h file-pattern` for more examples + -- "BufReadPre path/to/my-vault/*.md", + -- "BufNewFile path/to/my-vault/*.md", + -- }, + dependencies = { + -- Required. + "nvim-lua/plenary.nvim", + + -- see below for full list of optional dependencies 👇 + }, + opts = { + workspaces = { + { + name = "Brain", + path = "~/dox/brain", + overrides = { + disable_frontmatter = true, + } + }, + { + name = "no-vault", + path = function() + -- alternatively use the CWD: + -- return assert(vim.fn.getcwd()) + return assert(vim.fs.dirname(vim.api.nvim_buf_get_name(0))) + end, + overrides = { + notes_subdir = vim.NIL, -- have to use 'vim.NIL' instead of 'nil' + new_notes_location = "current_dir", + templates = { + folder = vim.NIL, + }, + disable_frontmatter = true, + }, + }, + }, + + templates = { + folder = "99 - Meta/Templates", + date_format = "%Y-%m-%d-%a", + time_format = "%H:%M", + }, + -- see below for full list of options 👇 + }, +} diff --git a/.config/nvim/lua/plugins/platformio.lua b/.config/nvim/lua/plugins/platformio.lua new file mode 100644 index 0000000..760de07 --- /dev/null +++ b/.config/nvim/lua/plugins/platformio.lua @@ -0,0 +1,6 @@ +return { + -- cmd = { "PIO" }, + lazy = false, + "sbatin/platformio.nvim", + dependencies = { "numToStr/FTerm.nvim" }, +} diff --git a/.config/nvim/lua/plugins/snacks.lua b/.config/nvim/lua/plugins/snacks.lua new file mode 100644 index 0000000..960b2a3 --- /dev/null +++ b/.config/nvim/lua/plugins/snacks.lua @@ -0,0 +1,8 @@ +return { + { + "folke/snacks.nvim", + opts = { + explorer = {enabled = false}, + } + }, +} |
