Added neovim config

This commit is contained in:
Robear Selwans
2026-03-23 00:17:39 +00:00
commit abdf0f8462
21 changed files with 631 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
require('settings/keymaps')
require('settings/options')
vim.pack.add(require('plugins'), { load = require('helpers/plugins').load_fn })
require('lsps')
-- Set Colorscheme
require('ayu').colorscheme()

View File

@@ -0,0 +1,36 @@
local saved_maps = {}
local function get_map(mode, lhs)
for _, map in ipairs(vim.api.nvim_get_keymap(mode)) do
if map.lhs == lhs then
return map
end
end
end
local function push_map(mode, lhs, new_rhs, opts)
local old = get_map(mode, lhs)
saved_maps[mode .. lhs] = old
vim.keymap.set(mode, lhs, new_rhs, opts)
end
local function pop_map(mode, lhs)
local old = saved_maps[mode .. lhs]
if old then
vim.keymap.set(old.mode, old.lhs, old.rhs or old.callback, {
noremap = old.noremap == 1,
silent = old.silent == 1,
expr = old.expr == 1,
nowait = old.nowait == 1,
})
else
vim.keymap.del(mode, lhs)
end
end
return {
push = push_map,
pop = pop_map,
}

View File

@@ -0,0 +1,18 @@
return {
load_fn = function(plug_data)
vim.cmd.packadd(plug_data.spec.name)
local status, config = pcall(require,'plugins/configs/'..plug_data.spec.name)
if status then
-- Call the configuration function (if exists)
if config.on_load ~= nil then
config.on_load()
end
if config.keymaps ~= nil then
for _,keymap in pairs(config.keymaps) do
vim.keymap.set(keymap.modes or 'n', keymap.keys, keymap.cmd, { desc = keymap.desc })
end
end
end
end
}

View File

@@ -0,0 +1,110 @@
local enabled_lsps_lspconf = {
'clangd',
'lua_ls',
-- 'rust_analyzer',
-- 'pylsp',
}
local enabled_lsps_custom = {
-- 'nu_lsp',
}
if #enabled_lsps_lspconf + #enabled_lsps_custom > 0 then
vim.lsp.config['*'] = {
-- capabilities = require('blink.cmp').get_lsp_capabilities(),
log_level = vim.lsp.protocol.MessageType.Warning,
}
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then
return
end
vim.lsp.inlay_hint.enable()
-- Setup Completion
if client:supports_method('textDocument/completion') then
-- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
-- client.server_capabilities.completionProvider.triggerCharacters = chars
vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger=true })
end
end,
})
vim.api.nvim_create_autocmd("InsertCharPre", {
callback = function(args)
if vim.fn.pumvisible() == 0 then
vim.lsp.completion.get()
end
end
})
end
for _, lsp_name in ipairs(enabled_lsps_custom) do
require("lsps/"..lsp_name)
end
vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig' })
for _, lsp_name in ipairs(enabled_lsps_lspconf) do
vim.lsp.config[lsp_name] = require('lspconfig.configs.'..lsp_name)
end
local overrides = {
-- ['lua_ls'] = {
-- settings = {
-- Lua = {
-- diagnostics = {
-- globals = {'vim'},
-- }
-- }
-- },
-- },
}
for _, lsp_name in ipairs(enabled_lsps_lspconf) do
if overrides[lsp_name] ~= nil then
local current = vim.lsp.config[lsp_name]
for key, value in pairs(overrides[lsp_name]) do
current[key] = value
end
vim.lsp.config[lsp_name] = current
end
vim.lsp.enable(lsp_name)
end
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
local config = {
virtual_text = true,
signs = {
active = signs,
text = {
[vim.diagnostic.severity.ERROR] = '',
[vim.diagnostic.severity.WARN] = '',
[vim.diagnostic.severity.HINT] = '',
[vim.diagnostic.severity.INFO] = '',
},
},
update_in_insert = false,
underline = true,
severity_sort = true,
float = {
focusable = false,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
vim.diagnostic.config(config)
vim.lsp.handlers["textDocument/hover"] = function() vim.lsp.buf.hover({ border = "rounded" }) end
vim.lsp.handlers["textDocument/signatureHelp"] = function() vim.lsp.buf.signature_help({ border = "rounded" }) end

View File

@@ -0,0 +1,12 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function()
require('lazydev').setup()
end,
-- Keymaps to be set after the plugin is loaded
keymaps = {
-- { [modes='n'], keys, cmd, desc }
}
}

View File

@@ -0,0 +1,14 @@
local leap_forward = function() require('leap').leap { opts = require('leap.user').with_traversal_keys('s', 'S') } end
local leap_backward = function() require('leap').leap { opts = require('leap.user').with_traversal_keys('s', 'S'), backward = true } end
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function() end,
-- Keymaps to be set after the plugin is loaded
keymaps = {
{ modes = {'n','x','o'}, keys = 's', cmd = leap_forward, desc = 'Forward' },
{ modes = {'n','x','o'}, keys = 'S', cmd = leap_backward, desc = 'Backward' },
}
}

View File

@@ -0,0 +1,6 @@
return
{
on_load = function()
require('mason').setup()
end,
}

View File

@@ -0,0 +1,11 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function()
require('mini.icons').setup()
require('mini.starter').setup()
if(vim.o.showtabline ~= 0) then
require('mini.tabline').setup()
end
end,
}

View File

@@ -0,0 +1,13 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function()
require('ayu').setup({
mirage = false, -- Set to `true` to use `mirage` variant instead of `dark` for dark background.
terminal = false, -- Set to `false` to let terminal manage its own colors.
overrides = {
VertSplit = { fg = '#FFFFFF', bg = '#FFFFFF' },
}, -- A dictionary of group names, each associated with a dictionary of parameters (`bg`, `fg`, `sp` and `style`) and colors in hex.
})
end,
}

View File

@@ -0,0 +1,14 @@
return
{
on_load = function()
local dap = require('dap')
local ui = require('dapui')
dap.listeners.before.attach.dapui_config = ui.open
dap.listeners.before.launch.dapui_config = ui.open
dap.listeners.before.event_terminated.dapui_config = ui.close
dap.listeners.before.event_exited.dapui_config = ui.close
ui.setup()
end
}

View File

@@ -0,0 +1,6 @@
return
{
on_load = function()
require('nvim-dap-virtual-text').setup()
end,
}

View File

@@ -0,0 +1,45 @@
return
{
on_load = function()
local dap = require('dap')
dap.adapters.codelldb = {
type = 'executable',
command = 'codelldb',
}
dap.configurations.c = {
{
name = 'Launch file',
type = 'codelldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
}
}
dap.listeners.before.attach.key_config = function()
require('helpers/kmstack').push('n', '<Down>', dap.step_over, {})
require('helpers/kmstack').push('n', '<Up>', dap.restart_frame, {})
require('helpers/kmstack').push('n', '<Right>', dap.step_into, {})
require('helpers/kmstack').push('n', '<Left>', dap.step_out, {})
end
dap.listeners.before.launch.key_config = dap.listeners.before.attach.key_config
dap.listeners.after.event_terminated.key_config = function()
require('helpers/kmstack').pop('n', '<Down>')
require('helpers/kmstack').pop('n', '<Up>')
require('helpers/kmstack').pop('n', '<Right>')
require('helpers/kmstack').pop('n', '<Left>')
end
dap.listeners.after.event_exited.key_config = dap.listeners.after.event_terminated.key_config
end,
keymaps = {
{ keys = '<leader>db', cmd = require('dap').toggle_breakpoint, desc = 'Toggle Breakpoint' },
{ keys = '<leader>dn', cmd = require('dap').step_over, desc = 'Step Over' },
},
}

View File

@@ -0,0 +1,18 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function()
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'c', 'lua' },
callback = function()
-- syntax highlighting, provided by Neovim
vim.treesitter.start()
-- folds, provided by Neovim
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.wo.foldmethod = 'expr'
-- indentation, provided by nvim-treesitter
-- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
end,
}

View File

@@ -0,0 +1,23 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function()
require("oil").setup{ watch_for_changes = true,
default_file_explorer = true,
view_options = {
show_hidden = true
},
float = {
border = 'single',
},
}
end,
-- Keymaps to be set after the plugin is loaded
keymaps = {
{ keys = '<leader>oo', cmd = require('oil').open, desc = 'Open' },
{ keys = '<leader>oc', cmd = require('oil').close, desc = 'Close' },
{ keys = '<leader>of', cmd = require('oil').toggle_float, desc = 'Toggle Floating' },
{ keys = '<leader>op', cmd = require('oil.actions').preview.callback, desc = 'Toggle Preview' },
}
}

View File

@@ -0,0 +1,12 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function()
require('overseer').setup()
end,
-- Keymaps to be set after the plugin is loaded
keymaps = {
-- { [modes='n'], keys, cmd, desc }
}
}

View File

@@ -0,0 +1,23 @@
local function tc(cmd,theme)
return "<cmd>Telescope "..cmd.." theme="..theme.."<CR>"
end
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function() end,
-- Keymaps to be set after the plugin is loaded
keymaps = {
{ keys="<leader>tf", cmd=tc("find_files" ,"dropdown"), desc="Files" },
{ keys="<leader>tt", cmd=tc("live_grep" ,"ivy") , desc="Text" },
{ keys="<leader>tb", cmd=tc("buffers" ,"dropdown"), desc="Buffers" },
{ keys="<leader>ts", cmd=tc("search_history","ivy") , desc="History" },
{ keys="<leader>tq", cmd=tc("quickfix" ,"ivy") , desc="Quickfix" },
{ keys="<leader>tr", cmd=tc("registers" ,"ivy") , desc="Registers" },
{ keys="<leader>ta", cmd=tc("aerial" ,"ivy") , desc="Aerial" },
{ keys="<leader>tc", cmd=tc("resume" ,"dropdown"), desc="Continue" },
{ keys="<leader>td", cmd=tc("diagnostics" ,"ivy") , desc="Diagnostics"},
{ keys="<leader>th", cmd=tc("help_tags" ,"ivy") , desc="Help Tags" },
}
}

View File

@@ -0,0 +1,10 @@
return
{
-- Configuration function to be run after the plugin is loaded
on_load = function() end,
-- Keymaps to be set after the plugin is loaded
keymaps = {
-- { [modes='n'], keys, cmd, desc }
}
}

View File

@@ -0,0 +1,30 @@
return
{
-- Colorschemes
'https://github.com/shatur/neovim-ayu',
'https://github.com/OXY2DEV/helpview.nvim',
-- Dependencies
'https://github.com/nvim-lua/plenary.nvim', -- For Telescope
'https://github.com/nvim-neotest/nvim-nio', -- For nvim-dap-ui
{ src = 'https://github.com/nvim-mini/mini.nvim', name = 'mini' },
{ src = 'https://github.com/stevearc/oil.nvim', name = 'oil' },
{ src = 'https://github.com/nvim-telescope/telescope.nvim', name = 'telescope' },
{ src = 'https://github.com/stevearc/overseer.nvim', name = 'overseer' },
{ src = 'https://codeberg.org/andyg/leap.nvim', name = 'leap' },
-- Debugging Support
'https://github.com/mfussenegger/nvim-dap',
'https://github.com/rcarriga/nvim-dap-ui',
'https://github.com/theHamsta/nvim-dap-virtual-text',
-- Easy Installers
'https://github.com/nvim-treesitter/nvim-treesitter',
{ src = 'https://github.com/mason-org/mason.nvim', name = 'mason' },
-- Misc.
{ src = 'https://github.com/folke/lazydev.nvim', name = 'lazydev' },
}

View File

@@ -0,0 +1,104 @@
local keymap = vim.keymap.set
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Modes
-- n = Normal
-- i = Insert
-- x = Visual
-- s = Select
-- v = Visual + Select
-- t = Term
-- c = Command
-- Normal --
-- Window Navigation --
keymap("n", "<C-h>", "<C-w>h", {})
keymap("n", "<C-j>", "<C-w>j", {})
keymap("n", "<C-k>", "<C-w>k", {})
keymap("n", "<C-l>", "<C-w>l", {})
-- Splits --
keymap("n", "<M-v>", ":vsplit<cr>", {})
keymap("n", "<M-s>", ":split<cr>", {})
-- Resize splits --
keymap("n", "<M-k>", ":resize +2<cr>", {})
keymap("n", "<M-j>", ":resize -2<cr>", {})
keymap("n", "<M-h>", ":vertical resize -2<cr>", {})
keymap("n", "<M-l>", ":vertical resize +2<cr>", {})
-- Navigate buffers --
keymap("n", "<leader>j", ":bnext<cr>", {})
keymap("n", "<leader>k", ":bprevious<cr>", {})
keymap("n", "<leader>d", ":bdelete<cr>", {})
-- Faster command --
keymap("n", ";", ":", {})
-- LSP Commands --
keymap("n", "<leader>l?", vim.lsp.buf.hover, {})
keymap("n", "<leader>li", vim.lsp.buf.implementation, {})
keymap("n", "<leader>ld", vim.lsp.buf.definition, {})
keymap("n", "<leader>lD", vim.lsp.buf.declaration, {})
keymap("n", "<leader>lR", vim.lsp.buf.rename, {})
keymap("n", "<leader>lca", vim.lsp.buf.code_action, {})
keymap("n", "<leader>lr", vim.lsp.buf.references, {})
keymap("n", "<leader>lf", vim.diagnostic.open_float, {})
keymap("n", "<leader>lF", vim.lsp.buf.format, {})
keymap("i", "<C-k>", vim.lsp.buf.signature_help, {})
keymap("i", "<C-space>", vim.lsp.completion.get, {})
-- Insert --
-- Quicker escape --
keymap("i", "jk", "<ESC>", {})
-- Move lines --
keymap("n", "<Left>", "<<", {})
keymap("n", "<Right>", ">>", {})
keymap("n", "<Up>", "dd2kp", {})
keymap("n", "<Down>", "ddp", {})
-- Visual --
-- Stay in indent mode --
keymap("v", "<Left>", "<gv", {})
keymap("v", "<Right>", ">gv", {})
-- Move text up and down
keymap("v", "<Up>", ":move '<-2<CR>gv-gv", {})
keymap("v", "<Down>", ":move '>+1<CR>gv-gv", {})
-- Paste overwrite selection
keymap("v", "p", '"_dP', {})
-- Terminal --
-- Better terminal navigation --
keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", {})
keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", {})
keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", {})
keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", {})
-- -------------------------------------------------------------------------------------
-- -------------------------------------------------------------------------------------
-- Tab Overloads
keymap("i", "<Tab>",
function()
if vim.fn.pumvisible() == 1 then
return '<C-n>'
else
return '<Tab>'
end
end,
{ expr = true, noremap = true, silent = true }
)
keymap("i", "<S-Tab>",
function()
if vim.fn.pumvisible() == 1 then
return '<C-p>'
else
return '<S-Tab>'
end
end,
{ expr = true, noremap = true, silent = true }
)

View File

@@ -0,0 +1,49 @@
vim.opt.backup = false -- Backup file creation
vim.opt.clipboard = "unnamedplus" -- Using system clipboard
vim.opt.cmdheight = 0
vim.opt.showcmdloc = 'statusline'
vim.opt.conceallevel = 0
vim.opt.fileencoding = "utf-8" -- File encoding
vim.opt.hlsearch = true -- Highlight search matches
vim.opt.ignorecase = true -- Ignore case in search patterns
vim.opt.mouse = "a" -- Use mouse in neovim
vim.opt.pumheight = 10 -- Pop-up menu height
vim.opt.showmode = false -- Show mode name
vim.opt.showtabline = 0 -- Show tabs (0: never, 1: when >=2 tabs present, 2: always)
vim.opt.smartcase = true -- Override ignorecase when needed
vim.opt.smartindent = true -- Smarter indentation
vim.opt.splitbelow = true -- Horizontal splits go below
vim.opt.splitright = true -- Vertical split go right
vim.opt.swapfile = false -- Swap file creation
vim.opt.termguicolors = true
vim.opt.timeoutlen = 1000 -- Time to wait for a mapped sequence to complete
vim.opt.undofile = true -- Persistent undo history
vim.opt.updatetime = 100 -- Faster completion (ms)
vim.opt.writebackup = false
vim.opt.expandtab = true -- Convert tabs to spaces
vim.opt.shiftwidth = 2 -- Number of spaces per indentation
vim.opt.tabstop = 2 -- Insert spaces per tab
vim.opt.cursorline = true -- Highlight the current line
vim.opt.number = true -- Set numbered lines
vim.opt.relativenumber = false -- Set relative numbered lines
vim.opt.numberwidth = 4 -- Set number column width
vim.opt.signcolumn = "yes" -- Always show sign column
vim.opt.wrap = false -- Text wrapping
vim.opt.scrolloff = 8
vim.opt.sidescrolloff = 8
-- vim.opt.lazyredraw = true -- Don't draw in the middle of bindings/macros
vim.opt.exrc = true
vim.opt.laststatus=3
vim.opt.completeopt = { "menuone", "noselect", "popup", "fuzzy" }
vim.opt.shortmess:append "c"
vim.opt.foldlevel=99
vim.opt.foldlevelstart=99
-- opt.shell = 'nu.exe'
vim.cmd "set whichwrap+=<,>,[,],h,l"
vim.cmd [[set iskeyword+=-]] -- Don't treat `-` as a word separator
vim.cmd [[set formatoptions-=cro]]
vim.cmd [[set fillchars+=vert:║]]

View File

@@ -0,0 +1,68 @@
{
"plugins": {
"helpview.nvim": {
"rev": "518789535a0cb146224a428edf93a70f98b795db",
"src": "https://github.com/OXY2DEV/helpview.nvim"
},
"lazydev": {
"rev": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d",
"src": "https://github.com/folke/lazydev.nvim"
},
"leap": {
"rev": "25d893149edfc831ba188f16448b255ab582544c",
"src": "https://codeberg.org/andyg/leap.nvim"
},
"mason": {
"rev": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65",
"src": "https://github.com/mason-org/mason.nvim"
},
"mini": {
"rev": "59f09943573c5348ca6c88393fa09ce3b66a7818",
"src": "https://github.com/nvim-mini/mini.nvim"
},
"neovim-ayu": {
"rev": "e5a9f0fa2918d6b5f57c21b3ac014314ee5e41c8",
"src": "https://github.com/shatur/neovim-ayu"
},
"nvim-dap": {
"rev": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5",
"src": "https://github.com/mfussenegger/nvim-dap"
},
"nvim-dap-ui": {
"rev": "cf91d5e2d07c72903d052f5207511bf7ecdb7122",
"src": "https://github.com/rcarriga/nvim-dap-ui"
},
"nvim-dap-virtual-text": {
"rev": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6",
"src": "https://github.com/theHamsta/nvim-dap-virtual-text"
},
"nvim-lspconfig": {
"rev": "841c6d4139aedb8a3f2baf30cef5327371385b93",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-nio": {
"rev": "21f5324bfac14e22ba26553caf69ec76ae8a7662",
"src": "https://github.com/nvim-neotest/nvim-nio"
},
"nvim-treesitter": {
"rev": "875515255192864c33981c3ed66ad94e561b904a",
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
},
"oil": {
"rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e",
"src": "https://github.com/stevearc/oil.nvim"
},
"overseer": {
"rev": "a2194447f4c5a1baf95139c5c7b539fa7b0d012f",
"src": "https://github.com/stevearc/overseer.nvim"
},
"plenary.nvim": {
"rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
"src": "https://github.com/nvim-lua/plenary.nvim"
},
"telescope": {
"rev": "5255aa27c422de944791318024167ad5d40aad20",
"src": "https://github.com/nvim-telescope/telescope.nvim"
}
}
}