diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..dbc863e --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1 @@ +require("config") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..5eb0d3f --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,16 @@ +{ + "conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" }, + "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.icons": { "branch": "main", "commit": "6787321f70d674a481776b7cc2c781fb7002c644" }, + "nord.nvim": { "branch": "master", "commit": "80c1e5321505aeb22b7a9f23eb82f1e193c12470" }, + "nvim-lspconfig": { "branch": "master", "commit": "a8ef5e6e497b3ebeaaf35b939c07c211563b2e05" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "slimline.nvim": { "branch": "main", "commit": "5a7e91619496c4655e02e7ba26aae6b9a5b5a564" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, + "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" } +} diff --git a/.config/nvim/lua/config/init.lua b/.config/nvim/lua/config/init.lua new file mode 100644 index 0000000..c09ad47 --- /dev/null +++ b/.config/nvim/lua/config/init.lua @@ -0,0 +1,3 @@ +require('config.lazy') +require('config.settings') +require('config.keybinds') diff --git a/.config/nvim/lua/config/keybinds.lua b/.config/nvim/lua/config/keybinds.lua new file mode 100644 index 0000000..f275792 --- /dev/null +++ b/.config/nvim/lua/config/keybinds.lua @@ -0,0 +1,5 @@ +-- Remap Ctrl + h/j/k/l for pane movement +vim.api.nvim_set_keymap('n', '', 'h', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'j', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'k', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'l', { noremap = true, silent = true }) diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..b78649b --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "nord" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/.config/nvim/lua/config/settings.lua b/.config/nvim/lua/config/settings.lua new file mode 100644 index 0000000..0539cc2 --- /dev/null +++ b/.config/nvim/lua/config/settings.lua @@ -0,0 +1,29 @@ +-- Line numbers +vim.wo.number = true + +-- Tabs +vim.o.expandtab = true +vim.o.smartindent = true +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 + +-- Clipboard +vim.o.clipboard = "unnamedplus" + +-- Restore cursor +local restore_cursor_augroup = vim.api.nvim_create_augroup("restore_cursor_shape_on_exit", { clear = true }) + +vim.api.nvim_create_autocmd({ "VimLeave" }, { + group = restore_cursor_augroup, + desc = "restore the cursor shape on exit of neovim", + command = "set guicursor=a:ver20", +}) + +-- Horizontal Split Line +vim.opt.laststatus = 3 + +-- Padding around current line +vim.opt.scrolloff = 5 + +-- Highlight current line +vim.opt.cursorline = true diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..995bd0b --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,7 @@ +return { + "lewis6991/gitsigns.nvim", + opt = { + current_line_blame = false, + }, + -- TODO: Update +} diff --git a/.config/nvim/lua/plugins/indent-blankline.lua b/.config/nvim/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..84cbd72 --- /dev/null +++ b/.config/nvim/lua/plugins/indent-blankline.lua @@ -0,0 +1,7 @@ +return { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + ---@module "ibl" + ---@type ibl.config + opts = {}, +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..d338b45 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,121 @@ +return { + { + "williamboman/mason.nvim", + cmd = "Mason", + }, + { + "williamboman/mason-lspconfig.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + require("mason").setup() + + require("mason-lspconfig").setup_handlers({ + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup({}) + end, + -- Next, you can provide a dedicated handler for specific servers. + -- For example, a handler override for the `rust_analyzer`: + -- ["rust_analyzer"] = function () + -- require("rust-tools").setup {} + -- end + }) + end, + }, + "neovim/nvim-lspconfig", + { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + cmd = { "ConformInfo" }, + opts = function() + local mason_reg = require("mason-registry") + + local formatters = {} + local formatters_by_ft = {} + + -- add diff langue vs filetype + local keymap = { + ["c++"] = "cpp", + ["c#"] = "cs", + } + + -- add dif conform vs mason + local name_map = { + ["cmakelang"] = "cmake_format", + ["deno"] = "deno_fmt", + ["elm-format"] = "elm_format", + ["gdtoolkit"] = "gdformat", + ["nixpkgs-fmt"] = "nixpkgs_fmt", + ["opa"] = "opa_fmt", + ["php-cs-fixer"] = "php_cs_fixer", + ["ruff"] = "ruff_format", + ["sql-formatter"] = "sql_formatter", + ["xmlformatter"] = "xmlformat", + } + + for _, pkg in pairs(mason_reg.get_installed_packages()) do + for _, type in pairs(pkg.spec.categories) do + -- only act upon a formatter + if type == "Formatter" then + -- if formatter doesn't have a builtin config, create our own from a generic template + if not require("conform").get_formatter_config(pkg.spec.name) then + -- the key of the entry to this table + -- is the name of the bare executable + -- the actual value may not be the absolute path + -- in some cases + local bin = next(pkg.spec.bin) + -- this should be replaced by a function + -- that quieries the configured mason install path + local prefix = vim.fn.stdpath("data") .. "/mason/bin/" + + formatters[pkg.spec.name] = { + command = prefix .. bin, + args = { "$FILENAME" }, + stdin = true, + require_cwd = false, + } + end + + -- finally add the formatter to it's compatible filetype(s) + for _, ft in pairs(pkg.spec.languages) do + local ftl = string.lower(ft) + local ready = mason_reg.get_package(pkg.spec.name):is_installed() + if ready then + if keymap[ftl] ~= nil then + ftl = keymap[ftl] + end + if name_map[pkg.spec.name] ~= nil then + pkg.spec.name = name_map[pkg.spec.name] + end + formatters_by_ft[ftl] = formatters_by_ft[ftl] or {} + table.insert(formatters_by_ft[ftl], pkg.spec.name) + end + end + end + end + end + + return { + format_on_save = { + lsp_fallback = true, + timeout_ms = 500, + }, + formatters = formatters, + formatters_by_ft = formatters_by_ft, + } + end, + keys = { + { + -- Customize or remove this keymap to your liking + "fm", + function() + require("conform").format({ async = true }) + end, + mode = "", + desc = "Format buffer", + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/mini_icons.lua b/.config/nvim/lua/plugins/mini_icons.lua new file mode 100644 index 0000000..0ad32be --- /dev/null +++ b/.config/nvim/lua/plugins/mini_icons.lua @@ -0,0 +1,3 @@ +return { + "echasnovski/mini.icons" +} diff --git a/.config/nvim/lua/plugins/nord.lua b/.config/nvim/lua/plugins/nord.lua new file mode 100644 index 0000000..f79f5c9 --- /dev/null +++ b/.config/nvim/lua/plugins/nord.lua @@ -0,0 +1,6 @@ +return { + "shaunsingh/nord.nvim", + config = function() + vim.cmd[[colorscheme nord]] + end, +} diff --git a/.config/nvim/lua/plugins/statusline.lua b/.config/nvim/lua/plugins/statusline.lua new file mode 100644 index 0000000..94cc96b --- /dev/null +++ b/.config/nvim/lua/plugins/statusline.lua @@ -0,0 +1,6 @@ +return { + "sschleemilch/slimline.nvim", + opts = { + style = "fg", + }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..80b6e62 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,18 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { "nvim-lua/plenary.nvim" }, + event = "VimEnter", + config = function() + local builtin = require("telescope.builtin") + vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) + + vim.keymap.set("n", "/", function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + winblend = 20, + previewer = false, + })) + end, { desc = "[/] Fuzzily search in current buffer" }) + end, +} diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..4048626 --- /dev/null +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -0,0 +1,11 @@ +return { + "akinsho/toggleterm.nvim", + cmd = "ToggleTerm", + keys = { + { "", "ToggleTerm", desc = "Toggle Terminal" }, + }, + version = "*", + opts = { + open_mapping = [[]], + }, +} diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..1b2e8ce --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,14 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = {}, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +}