commit db2c2f17f0c585257621cecf8cc771423ca13eb0 Author: Yasien Mac Mini Date: Tue Mar 17 13:54:28 2026 +0200 initial commit: Mzansi Neovim diff --git a/.gitingore b/.gitingore new file mode 100644 index 0000000..de0a590 --- /dev/null +++ b/.gitingore @@ -0,0 +1,4 @@ +*.swp +*.swo +undo/ +view/ diff --git a/.nvimlog b/.nvimlog new file mode 100644 index 0000000..e69de29 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e7df95d --- /dev/null +++ b/init.lua @@ -0,0 +1,3 @@ +require('config.options') +require('config.keybinds') +require('config.lazy') diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..c7ee034 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,23 @@ +{ + "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" }, + "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" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "flutter-tools.nvim": { "branch": "main", "commit": "677cc07c16e8b89999108d2ebeefcfc5f539b73c" }, + "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, + "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" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-lspconfig": { "branch": "master", "commit": "dc2f86d2b66a6e01a98c37cdadd3be3e90f8ab9a" }, + "nvim-treesitter": { "branch": "main", "commit": "2cc172c28e5550e00e6beead4599b1469469c1c7" }, + "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" } +} diff --git a/lua/config/keybinds.lua b/lua/config/keybinds.lua new file mode 100644 index 0000000..465a35c --- /dev/null +++ b/lua/config/keybinds.lua @@ -0,0 +1,2 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "cd", vim.cmd.Ex) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..f43bf5d --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,23 @@ +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 = { + { import = "plugins" }, + }, + -- remove change notifications + -- change_detection = { notify = false }, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..6937b88 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,4 @@ +vim.opt.number = true +vim.opt.cursorline = true +vim.opt.relativenumber = true +vim.opt.shiftwidth = 4 diff --git a/lua/plugins/colors.lua b/lua/plugins/colors.lua new file mode 100644 index 0000000..95e3722 --- /dev/null +++ b/lua/plugins/colors.lua @@ -0,0 +1,23 @@ +local function enable_transparency() + vim.api.nvim_set_hl(0, "Normal", {bg = "none"}) +end +return { + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + config = function() + vim.cmd([[colorscheme tokyonight]]) + enable_transparency() + end, + }, + { + "nvim-lualine/lualine.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + opts = { + theme = 'tokyonight', + } + } +} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 0000000..8320e2f --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,44 @@ +local conf = require("telescope.config").values +local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers").new({}, { + promt_title = "Harpoon Finder", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() +end + +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local harpoon = require("harpoon") + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + -- Basic UI and file management keymaps + vim.keymap.set("n", "a", function() harpoon:list():add() end, { desc = "Harpoon Add File" }) + vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, { desc = "Harpoon Menu" }) +vim.keymap.set("n", "fl", function() toggle_telescope(harpoon:list()) end,{ desc = "Open harpoon window" }) + + -- Quick navigation to files 1-4 + vim.keymap.set("n", "", function() harpoon:list():select(1) end, { desc = "Harpoon File 1" }) + vim.keymap.set("n", "", function() harpoon:list():select(2) end, { desc = "Harpoon File 2" }) + vim.keymap.set("n", "", function() harpoon:list():select(3) end, { desc = "Harpoon File 3" }) + vim.keymap.set("n", "", function() harpoon:list():select(4) end, { desc = "Harpoon File 4" }) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set("n", "", function() harpoon:list():prev() end, { desc = "Harpoon Prev" }) + vim.keymap.set("n", "", function() harpoon:list():next() end, { desc = "Harpoon Next" }) + end, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..3e071ec --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,120 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + require("mason").setup() + + local mason_lspconfig = require("mason-lspconfig") + -- We no longer need: local lspconfig = require("lspconfig") + + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + local servers = { + "lua_ls", + "pyright", + "dockerls", + "bashls", + "yamlls", + "jsonls", + "html", + "cssls", + "eslint", + "sqls", + "marksman", + } + + mason_lspconfig.setup({ + ensure_installed = servers, + }) + + -- Neovim 0.11+ approach: Use vim.lsp.config + for _, server_name in ipairs(servers) do + local config = { + capabilities = capabilities, + } + + if server_name == "lua_ls" then + config.settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + }, + } + end + + -- Enable the server configuration natively + vim.lsp.config(server_name, config) + vim.lsp.enable(server_name) + end + + -- Keybindings (unchanged) + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(ev) + local opts = { buffer = ev.buf } + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + end, + }) + end, + }, + { + "nvim-flutter/flutter-tools.nvim", + lazy = false, -- Load on startup to ensure it handles dartls correctly + dependencies = { + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", -- Optional but highly recommended for better UI + }, + config = function() + require("flutter-tools").setup({ + lsp = { + -- Pass your existing capabilities to the flutter-tools LSP config + capabilities = require("cmp_nvim_lsp").default_capabilities(), + -- You can add specific dartls settings here if needed + settings = { + showTodos = true, + completeFunctionCalls = true, + }, + }, + }) + end, + }, + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", -- Snippet engine is usually required by cmp configs + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }), + }) + end, + }, + } diff --git a/lua/plugins/oneliners.lua b/lua/plugins/oneliners.lua new file mode 100644 index 0000000..f469a44 --- /dev/null +++ b/lua/plugins/oneliners.lua @@ -0,0 +1,6 @@ +return { + { + -- Git Plugin + 'tpope/vim-fugitive', + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..49d1276 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,15 @@ +return { + 'nvim-telescope/telescope.nvim', version = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + -- optional but recommended + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) + vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..22a3eda --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,31 @@ +return { + "nvim-treesitter/nvim-treesitter", + lazy = false, + build = ":TSUpdate", + config = function() + require("nvim-treesitter").setup({ + install_dir = vim.fn.stdpath("data") .. "/site", + highlight = { enable = true }, + indent = { enable = true }, + autotag = { enable = true }, + ensure_installed = { + "lua", + "vim", + "vimdoc", + "query", + "dart", + "python", + "dockerfile", + "yaml", + "bash", + "json", + "html", + "css", + "javascript", + "sql", + "markdown", + "markdown_inline", + }, + }) + end, +}