commit 73972badc34bb24b97f2e40a629abbd086d9f273 Author: sailor Date: Wed Jun 3 22:47:03 2026 +0100 feat: add neovim configuration diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..865ca51 --- /dev/null +++ b/init.lua @@ -0,0 +1,3 @@ +require("config.options") +require("config.keymaps") +require("config.lazy") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..56ca7cf --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,25 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" }, + "catppuccin": { "branch": "main", "commit": "384f304c8b04664c9e0091fbfb3923c5f97c1bcf" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a676ab7282da8d651e175118bcf54483ca11e46d" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "9d6826582a3e8c84787bd7355df22a2812a1ad59" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-lspconfig": { "branch": "master", "commit": "4d0724be90b633ddce51b328a631060e6acd7d66" }, + "nvim-treesitter": { "branch": "main", "commit": "2f5d4c3f3c675962242096bcc8e586d76dd72eb2" }, + "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "e3c18ddd27a853f85a6f513a864cf4f2982b9f26" }, + "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..74b30d3 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,34 @@ +local map = vim.keymap.set + +-- Navigation +map("n", "pv", vim.cmd.Ex) + +-- Move lines up/down +map("v", "J", ":m '>+1gv=gv") +map("v", "K", ":m '<-2gv=gv") + +-- Keep cursor centered +map("n", "", "zz") +map("n", "", "zz") +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- Paste without losing register +map("x", "p", [["_dP]]) + +-- System clipboard +map("n", "y", [["+y]]) +map("v", "y", [["+y]]) +map("n", "Y", [["+Y]]) + +-- Delete to void +map("n", "d", [["_d]]) +map("v", "d", [["_d]]) + +-- Window splits +map("n", "sv", "v") +map("n", "sh", "s") +map("n", "", "h") +map("n", "", "l") +map("n", "", "j") +map("n", "", "k") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..e54fc4f --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,13 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", "clone", "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("plugins", { + rocks = { enabled = false }, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..e575b35 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,21 @@ +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.wrap = false +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undofile = true +vim.opt.hlsearch = false +vim.opt.incsearch = true +vim.opt.termguicolors = true +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.updatetime = 50 +vim.opt.colorcolumn = "80" +vim.opt.clipboard = "unnamedplus" +vim.g.mapleader = " " +vim.g.loaded_perl_provider = 0 +vim.g.loaded_ruby_provider = 0 diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..81b32e3 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,19 @@ +return { + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + require("catppuccin").setup({ + flavour = "mocha", + integrations = { + treesitter = true, + telescope = true, + which_key = true, + mason = true, + }, + }) + vim.cmd.colorscheme("catppuccin") + end, + }, +} diff --git a/lua/plugins/extras.lua b/lua/plugins/extras.lua new file mode 100644 index 0000000..05f1b63 --- /dev/null +++ b/lua/plugins/extras.lua @@ -0,0 +1,51 @@ +return { + -- Status line + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("lualine").setup({ options = { theme = "catppuccin-mocha" } }) + + end, + }, + -- Auto pairs + { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup() + end, + }, + -- Comment toggling + { + "numToStr/Comment.nvim", + config = function() + require("Comment").setup() + end, + }, + -- Git signs in gutter + { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup() + end, + }, + -- Which key helper + { + "folke/which-key.nvim", + config = function() + require("which-key").setup() + end, + }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + vim.keymap.set("n", "e", ":Neotree toggle") + end, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..a5bc4a7 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,101 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + dependencies = { "williamboman/mason.nvim" }, + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { + "pyright", + "clangd", + "rust_analyzer", + "bashls", + "lua_ls", + }, + automatic_installation = true, + }) + end, + }, + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + local capabilities = require("cmp_nvim_lsp").default_capabilities() + vim.lsp.config("*", { capabilities = capabilities }) + vim.lsp.enable({ "pyright", "clangd", "rust_analyzer", "bashls", "lua_ls" }) + vim.diagnostic.config({ + virtual_text = true, + signs = true, + underline = true, + update_in_insert = false, + }) + + vim.keymap.set("n", "gd", vim.lsp.buf.definition) + vim.keymap.set("n", "K", vim.lsp.buf.hover) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action) + vim.keymap.set("n", "rn", vim.lsp.buf.rename) + vim.keymap.set("n", "e", vim.diagnostic.open_float) + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) + vim.keymap.set("n", "]d", vim.diagnostic.goto_next) + end, + }, + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.confirm({ select = true }) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + }, +} diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua new file mode 100644 index 0000000..e3ac8bf --- /dev/null +++ b/lua/plugins/markdown.lua @@ -0,0 +1 @@ +return { { "MeanderingProgrammer/render-markdown.nvim", dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, opts = {} } } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..9573a98 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,13 @@ +return { + { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local builtin = require("telescope.builtin") + vim.keymap.set("n", "ff", builtin.find_files) + vim.keymap.set("n", "fg", builtin.live_grep) + vim.keymap.set("n", "fb", builtin.buffers) + vim.keymap.set("n", "fh", builtin.help_tags) + end, + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..7e07fa2 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,15 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + lazy = false, + config = function() + require("nvim-treesitter.config").setup({ + ensure_installed = { "c", "cpp", "python", "rust", "bash", "lua", "vim", "vimdoc" }, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, + }, +}