Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
ed6b02924f WIP: Start moving neovim config to lua 2025-05-15 18:20:49 +01:00
11 changed files with 305 additions and 0 deletions

View file

4
.config/nvim/init.lua Normal file
View file

@ -0,0 +1,4 @@
require("configs")
require("plugins")
require("keybindings")
require("functions")

View file

@ -0,0 +1,36 @@
-- Imports
local U = require("utils")
-- Neovim Alias
local exec = vim.api.nvim_exec -- execute Vimscript
local api = vim.api -- neovim commands
local autocmd = vim.api.nvim_create_autocmd -- execute autocommands
local set = vim.opt -- global options
local cmd = vim.cmd -- execute Vim commands
-- Configs
vim.g.mapleader = " "
set.compatible = false
set.showmatch = true
set.ignorecase = true
set.mouse = "v"
set.hlsearch = true
set.incsearch = true
set.tabstop = 4
set.softtabstop = 4
set.expandtab = true
set.shiftwidth = 4
set.autoindent = true
set.number = true
set.relativenumber = true
set.wildmode = "longest,list"
set.cc = "80"
set.mouse = "a"
set.clipboard = "unnamedplus"
set.cursorline = true
set.ttyfast = true
set.fixeol = false
set.splitright = true
set.splitbelow = true
set.termguicolors = true

View file

View file

View file

@ -0,0 +1,50 @@
-- Helper function
function map(mode, lhs, rhs, opts)
local options = { noremap = true }
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.keymap.set(mode, lhs, rhs, options)
end
local opts = { silent = true, noremap = true, expr = true }
-- Move Lines Up/Down
map("i", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
map("i", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
map("v", "<A-j>", ":m '>+1<CR>gv=gv", opts)
map("v", "<A-k>", ":m '<-2<CR>gv=gv", opts)
map("n", "<A-h>", "<C-W>H", opts)
map("n", "<A-j>", "<C-W>J", opts)
map("n", "<A-k>", "<C-W>K", opts)
map("n", "<A-l>", "<C-W>L", opts)
map("n", "<C-h>", "<C-w>h", opts)
map("n", "<C-j>", "<C-w>j", opts)
map("n", "<C-k>", "<C-w>k", opts)
map("n", "<C-l>", "<C-w>l", opts)
map("n", "gf", ":vert winc f<cr>", opts)
map("i", "<cr>", [[coc#pum#visible() ? coc#_select_confirm() : "\<C-g>u\<CR>"]], opts)
map("i", "<Tab>", [[coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"]], opts)
map("i", "<S-Tab>", [[coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"]], opts)
map("n", "<leader>n", ":NERDTreeFocus<CR>", opts)
map("n", "<C-n>", ":NERDTree<CR>", opts)
map("n", "<C-t>", ":NERDTreeToggle<CR>", opts)
map("n", "<C-f>", ":NERDTreeFind<CR>", opts)
map("n", "<leader>ha", function() require("harpoon.mark").add_file() end, opts)
map("n", "<leader>hh", function() require("harpoon.ui").toggle_quick_menu() end, opts)
map("n", "<leader>1", [[<cmd>lua require("harpoon.ui").nav_file(1)<CR>]], opts)
map("n", "<leader>2", [[<cmd>lua require("harpoon.ui").nav_file(2)<CR>]], opts)
map("n", "<leader>3", [[<cmd>lua require("harpoon.ui").nav_file(3)<CR>]], opts)
map("n", "<leader>4", [[<cmd>lua require("harpoon.ui").nav_file(4)<CR>]], opts)
map("n", "<A-[>", [[<cmd>lua require("harpoon.ui").nav_prev()<CR>]], opts)
map("n", "<A-]>", [[<cmd>lua require("harpoon.ui").nav_next()<CR>]], opts)
map("n", "<leader>ff", ":FZF<CR>", opts)
map("n", "mm", ":nohl<CR>", opts)

View file

@ -0,0 +1,41 @@
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
packer_bootstrap =
vim.fn.system({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path})
end
-- Register Packer with vim
vim.api.nvim_cmd({
cmd = "packadd",
args = {"packer.nvim"},
}, {})
return require("packer").startup {
function(use)
-- Packer can manage itself
use "wbthomason/packer.nvim"
-- Plugins go here
use 'dracula/vim'
use 'ryanoasis/vim-devicons'
-- use 'SirVer/ultisnips'
use 'honza/vim-snippets'
use 'scrooloose/nerdtree'
use 'preservim/nerdcommenter'
use 'mhinz/vim-startify'
use {'neoclide/coc.nvim', branch = 'release'}
use 'nvim-lua/plenary.nvim'
use 'ThePrimeagen/harpoon'
use 'junegunn/fzf'
use 'junegunn/fzf.vim'
use 'neovim/nvim-lspconfig'
use 'jose-elias-alvarez/null-ls.nvim'
use 'MunifTanjim/prettier.nvim'
use 'OmniSharp/omnisharp-vim'
-- Install and compile Plugins
if packer_bootstrap then
require("packer").sync()
end
end
}

View file

View file

View file

@ -0,0 +1,174 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/vylpes/.cache/nvim/packer_hererocks/2.1.1741730670/share/lua/5.1/?.lua;/home/vylpes/.cache/nvim/packer_hererocks/2.1.1741730670/share/lua/5.1/?/init.lua;/home/vylpes/.cache/nvim/packer_hererocks/2.1.1741730670/lib/luarocks/rocks-5.1/?.lua;/home/vylpes/.cache/nvim/packer_hererocks/2.1.1741730670/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/vylpes/.cache/nvim/packer_hererocks/2.1.1741730670/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["coc.nvim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/coc.nvim",
url = "https://github.com/neoclide/coc.nvim"
},
fzf = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/fzf",
url = "https://github.com/junegunn/fzf"
},
["fzf.vim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/fzf.vim",
url = "https://github.com/junegunn/fzf.vim"
},
harpoon = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/harpoon",
url = "https://github.com/ThePrimeagen/harpoon"
},
nerdcommenter = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/nerdcommenter",
url = "https://github.com/preservim/nerdcommenter"
},
nerdtree = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/nerdtree",
url = "https://github.com/scrooloose/nerdtree"
},
["null-ls.nvim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/null-ls.nvim",
url = "https://github.com/jose-elias-alvarez/null-ls.nvim"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["omnisharp-vim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/omnisharp-vim",
url = "https://github.com/OmniSharp/omnisharp-vim"
},
["packer.nvim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["prettier.nvim"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/prettier.nvim",
url = "https://github.com/MunifTanjim/prettier.nvim"
},
vim = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/vim",
url = "https://github.com/dracula/vim"
},
["vim-devicons"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/vim-devicons",
url = "https://github.com/ryanoasis/vim-devicons"
},
["vim-snippets"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/vim-snippets",
url = "https://github.com/honza/vim-snippets"
},
["vim-startify"] = {
loaded = true,
path = "/home/vylpes/.local/share/nvim/site/pack/packer/start/vim-startify",
url = "https://github.com/mhinz/vim-startify"
}
}
time([[Defining packer_plugins]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end