This commit is contained in:
2025-09-19 19:57:27 +02:00
commit e4bca2cc5d
19 changed files with 480 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
lazy-lock.json

20
init.lua Normal file
View File

@ -0,0 +1,20 @@
-- 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)
-- load plugins
require("config.config")
require("lazy").setup("plugins")

3
lua/config/config.lua Normal file
View File

@ -0,0 +1,3 @@
require("config.set")
require("config.remaps")
require("config.gui")

15
lua/config/gui.lua Normal file
View File

@ -0,0 +1,15 @@
local alpha = function()
return string.format("%x", math.floor(255 * vim.g.transparency or 0.8))
end
if vim.g.neovide then
vim.o.guifont = "Envy Code R:h18" -- text below applies for VimScript
vim.g.transparency = 0
vim.g.neovide_transparency = 1
vim.g.neovide_background_color = "#0f1117" .. alpha()
vim.g.neovide_scale_factor = 1.0
vim.g.neovide_window_blurred = true
vim.g.neovide_cursor_animation_length = 0.08
vim.g.neovide_cursor_trail_size = 0.5
vim.g.neovide_scroll_animation_length = 0.1
end

21
lua/config/remaps.lua Normal file
View File

@ -0,0 +1,21 @@
local map = vim.api.nvim_set_keymap
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- netrw
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- move
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- del line
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- ?
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")

30
lua/config/set.lua Normal file
View File

@ -0,0 +1,30 @@
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
vim.cmd("highlight Normal ctermbg=NONE")
vim.cmd("highlight NonText ctermbg=NONE")

60
lua/plugins/cmp.lua Normal file
View File

@ -0,0 +1,60 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-buffer",
"onsails/lspkind.nvim", -- Pictograms
},
config = function()
local cmp = require("cmp")
vim.cmd("highlight FloatBorder guibg=NONE")
cmp.setup({
completion = {
completeopt = "menu,menuone,noinsert",
},
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<tab>"] = cmp.mapping.confirm({ select = true }),
["<C-g>"] = function()
if cmp.visible_docs() then
cmp.close_docs()
else
cmp.open_docs()
end
end,
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "buffer" },
}),
formatting = {
format = require("lspkind").cmp_format({
mode = "symbol_text",
maxwidth = {
-- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- can also be a function to dynamically calculate max width such as
-- menu = function() return math.floor(0.45 * vim.o.columns) end,
menu = 50, -- leading text (labelDetails)
abbr = 50, -- actual suggestion item
},
}),
},
})
end,
}

34
lua/plugins/colors.lua Normal file
View File

@ -0,0 +1,34 @@
return {
{
"ellisonleao/gruvbox.nvim",
priority = 1000,
config = function()
-- Default options:
require("gruvbox").setup({
terminal_colors = true, -- add neovim terminal colors
undercurl = true,
underline = true,
bold = true,
italic = {
strings = true,
emphasis = true,
comments = true,
operators = false,
folds = true,
},
strikethrough = true,
invert_selection = false,
invert_signs = false,
invert_tabline = false,
invert_intend_guides = false,
inverse = true, -- invert background for search, diffs, statuslines and errors
contrast = "hard", -- can be "hard", "soft" or empty string
palette_overrides = {},
overrides = {},
dim_inactive = false,
transparent_mode = false,
})
vim.cmd("colorscheme gruvbox")
end,
},
}

View File

@ -0,0 +1,23 @@
return {
"stevearc/conform.nvim",
opts = {},
config = function()
local conform = require("conform")
conform.setup({
scala = { "scalafmt" },
formatters_by_ft = {
lua = { "stylua" },
rust = {
"rustfmt",
},
},
format_on_save = {
timeout_ms = 500,
},
})
conform.formatters.rustfmt = {
prepend_args = { "--config-path", "/home/albin/coding-projects/rustfmt.toml" },
}
end,
}

30
lua/plugins/harpoon.lua Normal file
View File

@ -0,0 +1,30 @@
return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
harpoon:setup()
vim.keymap.set("n", "<leader>a", function()
harpoon:list():add()
end)
vim.keymap.set("n", "<leader>e", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
vim.keymap.set("n", "<C-h>", function()
harpoon:list():select(1)
end)
vim.keymap.set("n", "<C-t>", function()
harpoon:list():select(2)
end)
vim.keymap.set("n", "<C-n>", function()
harpoon:list():select(3)
end)
vim.keymap.set("n", "<C-s>", function()
harpoon:list():select(4)
end)
end,
}

22
lua/plugins/html.lua Normal file
View File

@ -0,0 +1,22 @@
-- For automatically closing html tags when typed
return {
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup({
opts = {
-- Defaults
enable_close = true, -- Auto close tags
enable_rename = true, -- Auto rename pairs of tags
enable_close_on_slash = false, -- Auto close on trailing </
},
-- Also override individual filetype configs, these take priority.
-- Empty by default, useful if one of the "opts" global settings
-- doesn't work well in a specific filetype
per_filetype = {
["html"] = {
enable_close = true,
},
},
})
end,
}

92
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,92 @@
return {
{
"neovim/nvim-lspconfig",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
},
config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local nvim_lsp = require("lspconfig")
-- LUA
nvim_lsp.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim", "describe", "it" },
},
hint = {
enable = true,
},
},
},
})
-- RUST (in rust.lua)
-- HTML
nvim_lsp.html.setup({ capabilities = capabilities })
nvim_lsp.cssls.setup({
capabilities = capabilities,
})
-- JS
nvim_lsp.ts_ls.setup({ capabilities = capabilities })
-- CLANGD
nvim_lsp.clangd.setup({ capabilities = capabilities })
nvim_lsp.ocamllsp.setup({ capabilities = capabilities })
nvim_lsp.r_language_server.setup({ capabilities = capabilities })
--vim.lsp.enable("r_language_server")
vim.lsp.enable("metals")
local hl_groups = {
"DiagnosticUnderlineError",
"DiagnosticUnderlineWarn",
"DiagnosticUnderlineInfo",
"DiagnosticUnderlineHint",
}
for _, hl in ipairs(hl_groups) do
vim.cmd.highlight(hl .. " gui=undercurl")
end
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
signs = true,
update_in_insert = false,
show_diagnostic_autocmds = { "InsertLeave", "TextChanged" },
})
-- Not working for some weird reason ...
vim.diagnostic.config({
virtual_text = false,
float = {
header = false,
border = "rounded",
focusable = true,
},
})
-- Mappings
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local opts = { buffer = ev.buf }
vim.keymap.set("n", "<leader>t", vim.diagnostic.open_float)
vim.keymap.set("n", "<leader>sr", vim.lsp.buf.rename)
vim.keymap.set("n", "<leader>gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "<leader>gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<leader>f", function()
vim.lsp.buf.format({ async = true })
end, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
end,
})
end,
},
}

View File

@ -0,0 +1,7 @@
return {
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
config = function()
require("lsp_lines").setup()
vim.diagnostic.config({ virtual_lines = { only_current_line = true } })
end,
}

11
lua/plugins/ltex.lua Normal file
View File

@ -0,0 +1,11 @@
return {
{
"lervag/vimtex",
lazy = false, -- we don't want to lazy load VimTeX
-- tag = "v2.15", -- uncomment to pin to a specific release
init = function()
-- VimTeX configuration goes here, e.g.
vim.g.vimtex_view_method = "zathura"
end
}
}

1
lua/plugins/metals.lua Normal file
View File

@ -0,0 +1 @@
return {}

3
lua/plugins/noconf.lua Normal file
View File

@ -0,0 +1,3 @@
return {
"nvim-treesitter/nvim-treesitter"
}

47
lua/plugins/r.lua Normal file
View File

@ -0,0 +1,47 @@
return {
"R-nvim/R.nvim",
-- Only required if you also set defaults.lazy = true
lazy = false,
-- R.nvim is still young and we may make some breaking changes from time
-- to time (but also bug fixes all the time). If configuration stability
-- is a high priority for you, pin to the latest minor version, but unpin
-- it and try the latest version before reporting an issue:
-- version = "~0.1.0"
config = function()
-- Create a table with the options to be passed to setup()
---@type RConfigUserOpts
local opts = {
hook = {
on_filetype = function()
vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
end,
},
R_args = { "--quiet", "--no-save" },
min_editor_width = 72,
rconsole_width = 78,
objbr_mappings = { -- Object browser keymap
c = "class", -- Call R functions
["<localleader>gg"] = "head({object}, n = 15)", -- Use {object} notation to write arbitrary R code.
v = function()
-- Run lua functions
require("r.browser").toggle_view()
end,
},
disable_cmds = {
"RClearConsole",
"RCustomStart",
"RSPlot",
"RSaveClose",
},
}
-- Check if the environment variable "R_AUTO_START" exists.
-- If using fish shell, you could put in your config.fish:
-- alias r "R_AUTO_START=true nvim"
-- if vim.env.R_AUTO_START == "true" then
opts.auto_start = "on startup"
opts.objbr_auto_start = true
-- end
require("r").setup(opts)
end,
}

48
lua/plugins/rust.lua Normal file
View File

@ -0,0 +1,48 @@
return {
"mrcjkb/rustaceanvim",
version = "^5", -- Recommended
lazy = false, -- This plugin is already lazy
config = function()
vim.g.rustaceanvim = {
-- Plugin configuration
tools = {},
-- LSP configuration
server = {
capabilities = {
textDocument = {
completion = {
completionItem = {
snippetSupport = false,
},
},
},
},
on_attach = function(client, bufnr)
-- you can also put keymaps in here
vim.keymap.set("n", "<leader>ca", function()
vim.cmd.RustLsp("codeAction") -- supports rust-analyzer's grouping
-- or vim.lsp.buf.codeAction() if you don't want grouping.
end, { silent = true, buffer = bufnr })
vim.keymap.set(
"n",
"<leader>t", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions
function()
vim.cmd.RustLsp({ "renderDiagnostic", "current" }) -- defaults to 'cycle'
end,
{ silent = true, buffer = bufnr }
)
end,
default_settings = {
-- rust-analyzer language server configuration
["rust-analyzer"] = {
check = {
command = "clippy",
},
},
},
},
-- DAP configuration
dap = {},
}
end,
}

12
lua/plugins/telescope.lua Normal file
View File

@ -0,0 +1,12 @@
return {
{
"nvim-telescope/telescope.nvim",
tag = "0.1.6",
dependencies = { "nvim-lua/plenary.nvim" },
init = function ()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
end
},
}