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/config | |
| parent | 2e904234a732318e759272900a8a3383e1d3ac48 (diff) | |
add neovim configuration
Diffstat (limited to '.config/nvim/lua/config')
| -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 |
4 files changed, 186 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" |
