commit cb21bbc1a73a7abd12d9c467033b66811360a9b4 Author: Keyoonz Date: Mon Aug 11 23:59:08 2025 +0200 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..219a31a --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# KeoviZ + +Keyonz's Neovim config. + +Careful the colorscheme is supposed to work with (KonfiZ)[https://github.com/Keyoonz/KonfiZ] which generates automatically the colors based on the wallpaper. + +## Installation +If you already have a config backup it or remove it and then you are good to install this configuration. + +```bash +git clone https://github.com/Keyoonz/KeoviZ ~/.config/nvim +``` diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c67a70c --- /dev/null +++ b/init.lua @@ -0,0 +1,3 @@ +require("config.keymaps") +require("config.options") +require("config.lazy") diff --git a/lua/assets/icons.lua b/lua/assets/icons.lua new file mode 100644 index 0000000..a9dfa0b --- /dev/null +++ b/lua/assets/icons.lua @@ -0,0 +1,8 @@ +return { + diagnostics = { + Error = "", + Warn = "", + Info = "", + Hint = "", + } +} diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..801dda7 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,23 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.keymap.set("n", "c", "", { desc = "lsp" }) +vim.keymap.set("n", "cd", function() + vim.diagnostic.open_float() +end, { desc = "Show diagnostics" }) +vim.keymap.set("n", "cf", function() + vim.lsp.buf.format() +end, { desc = "Format buffer" }) +vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, { desc = "code actions" }) + +vim.keymap.set('n', '', 'h', { desc = "go to left window" }) +vim.keymap.set('n', '', 'l', { desc = "go to left window" }) +vim.keymap.set('n', '', 'j', { desc = "go to left window" }) +vim.keymap.set('n', '', 'k', { desc = "go to left window" }) + +vim.keymap.set('n', '', ':m .-2==', { desc = "Swap with above line" }) +vim.keymap.set('n', '', ':m .1==', { desc = "Swap with above line" }) + +vim.keymap.set('n', '', function() + vim.cmd("nohlsearch") +end, { desc = "Clear search result" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/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 = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..7b268a3 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,15 @@ +vim.opt.list = true +vim.opt.listchars = { + tab = "> ", + trail = "-", + nbsp = "+", +} + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.expandtab = false + +vim.opt.cmdheight = 0 diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..551ec11 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,29 @@ +return { + 'akinsho/bufferline.nvim', + event = "VeryLazy", + config = function() + vim.o.showtabline = 2 + + require("bufferline").setup({ + options = { + mode = "buffers", + always_show_bufferline = false, + numbers = "none", + diagnostics = "nvim_lsp", + separator_style = "slant", + show_buffer_close_icons = true, + show_close_icon = false, + close_command = function(n) Snacks.bufdelete(n) end, + offsets = { + { + filetype = "snacks_layout_box", + }, + } + } + }) + end, + keys = { + { "", "BufferLineCyclePrev", desc = "Prev Buffer" }, + { "", "BufferLineCycleNext", desc = "Next Buffer" }, + } +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..d3793bb --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,53 @@ +return { + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = function(fallback) + if luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, + [""] = function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + } +} diff --git a/lua/plugins/fold.lua b/lua/plugins/fold.lua new file mode 100644 index 0000000..d4c740a --- /dev/null +++ b/lua/plugins/fold.lua @@ -0,0 +1,28 @@ +return { + "kevinhwang91/nvim-ufo", + dependencies = { + "kevinhwang91/promise-async", -- required by nvim-ufo + "nvim-treesitter/nvim-treesitter" + }, + config = function() + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "v:lua.require('ufo').foldexpr()" + vim.opt.foldlevel = 99 -- open all folds initially + vim.opt.foldlevelstart = 99 -- set foldlevel when buffer loads + + + local ufo = require('ufo') + + -- Optional: keymaps for folding + vim.keymap.set('n', 'zR', ufo.openAllFolds) + vim.keymap.set('n', 'zM', ufo.closeAllFolds) + vim.keymap.set('n', 'K', function() + local winid = ufo.peekFoldedLinesUnderCursor() + if not winid then + vim.lsp.buf.hover() + end + end) + + ufo.setup() + end, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..636561b --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,28 @@ +return { + { + 'mason-org/mason.nvim', + opts = {}, + }, + { + 'mason-org/mason-lspconfig.nvim', + opts = { + ensure_installed = { + 'lua_ls', + 'clangd', + 'harper_ls', + }, + automatic_enable = { + exclude = { + 'harper_ls', + }, + }, + }, + }, + { + 'neovim/nvim-lspconfig', + config = function() + local lspconfig = require 'lspconfig' + lspconfig.harper_ls.setup { filetypes = { 'markdown' } } + end, + }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..79984ed --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,65 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + local lualine = require("lualine") + local icons = require("assets.icons") + local default_config = { + options = { + theme = "nightfly", + globalstatus = true, + section_separators = '', + component_separators = '', + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch' }, + lualine_c = { + "filename", + { + "diagnostics", + symbols = { + error = icons.diagnostics.Error, + warn = icons.diagnostics.Warn, + info = icons.diagnostics.Info, + hint = icons.diagnostics.Hint, + }, + } + }, + lualine_x = { 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + extensions = { + 'lazy', + 'mason', + }, + } + -- Minimal config for Snacks Explorer + local explorer_config = { + sections = { + lualine_a = { 'mode' }, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { + function() return "Explorer" end + } + } + } + -- Setup default lualine on startup + lualine.setup(default_config) + -- Autocommand to switch layout when Snacks Explorer is open + vim.api.nvim_create_autocmd({ "BufEnter", "WinEnter" }, { + callback = function() + local filetype = vim.bo.filetype + if filetype:match("snacks_picker_list") then + require("lualine").setup(explorer_config) + else + require("lualine").setup(default_config) + end + end + }) + end, +} diff --git a/lua/plugins/nvim-kolorz.lua b/lua/plugins/nvim-kolorz.lua new file mode 100644 index 0000000..919d5b3 --- /dev/null +++ b/lua/plugins/nvim-kolorz.lua @@ -0,0 +1,9 @@ +return { + "Keyoonz/nvim-kolorz", + name = "nvim-kolorz", + lazy = false, + priority = 1000, + config = function() + vim.cmd("colorscheme nvim-kolorz") + end, +} diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua new file mode 100644 index 0000000..a840ce2 --- /dev/null +++ b/lua/plugins/snacks.lua @@ -0,0 +1,57 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + explorer = { + enabled = true, + }, + bufdelete = { + enabled = true, + }, + picker = { + enabled = true, + }, + quickfile = { + enabled = true, + }, + }, + keys = { + -- explorer + { "e", function() Snacks.explorer() end, desc = "File Explorer" }, + -- Files + { "f", "", desc = "Files" }, + { "fd", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, + { "ff", function() Snacks.picker.files() end, desc = "Find Files" }, + { "fb", function() Snacks.picker.buffers() end, desc = "Buffers" }, + { "fc", function() Snacks.picker.files({ cwd = vim.fn.stdpath("config") }) end, desc = "Find Config File" }, + { "fr", function() Snacks.picker.recent() end, desc = "Recent" }, + { "f/", function() Snacks.picker.lines() end, desc = "Grep Lines" }, + -- picker + { "/", function() Snacks.picker.grep() end, desc = "Grep" }, + { ":", function() Snacks.picker.command_history() end, desc = "Command History" }, + -- -- Grep + { "sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" }, + { "sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" }, + { "sg", function() Snacks.picker.grep() end, desc = "Grep" }, + { "sw", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } }, + -- -- search + { 'sh', function() Snacks.picker.search_history() end, desc = "Search History" }, + { "sc", function() Snacks.picker.command_history() end, desc = "Command History" }, + { "sC", function() Snacks.picker.commands() end, desc = "Commands" }, + { "sD", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, + { "sd", function() Snacks.picker.diagnostics_buffer() end, desc = "Buffer Diagnostics" }, + { "sH", function() Snacks.picker.help() end, desc = "Help Pages" }, + { "si", function() Snacks.picker.icons() end, desc = "Icons" }, + { "sm", function() Snacks.picker.marks() end, desc = "Marks" }, + { "su", function() Snacks.picker.undo() end, desc = "Undo History" }, + { "uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" }, + -- -- LSP + { "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition" }, + { "gD", function() Snacks.picker.lsp_declarations() end, desc = "Goto Declaration" }, + { "gr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" }, + { "gi", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" }, + { "gt", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" }, + } +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..84d5d53 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,18 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + lazy = false, + build = ":TSUpdate", + config = function() + require 'nvim-treesitter.configs'.setup { + auto_install = true, + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + } + end + } +}