feat: initial commit of Ela's Arch config. :)

This commit is contained in:
Philomena 2024-07-22 22:14:21 +02:00 committed by Philomena
commit 9ed00ff30c
59 changed files with 2769 additions and 0 deletions

View file

@ -0,0 +1,18 @@
-- Install Lazy if not installed yet
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("config.options")
require("config.autocmds")
require("lazy").setup("plugins", { defaults = { version = "*" } })

View file

@ -0,0 +1,16 @@
-- Strip trailing whitespaces on save
local clean_whitespace_group = vim.api.nvim_create_augroup("CleanWhitespace", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = clean_whitespace_group,
command = "%s/\\s\\+$//e",
})
-- Enable spell checking for certain file types
local enable_spell_check_group = vim.api.nvim_create_augroup("EnableSpellCheck", { clear = true })
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
group = enable_spell_check_group,
pattern = { "*.txt", "*.md", "*.tex" },
callback = function()
vim.opt_local.spell = true
end,
})

View file

@ -0,0 +1,19 @@
vim.g.mapleader = " " -- Set leader key
vim.g.maplocalleader = " " -- Set local leader key
vim.o.completeopt = "menuone,noselect" -- Have a better completion experience
vim.opt.breakindent = true -- Keep indentation for line breaks
vim.opt.clipboard = "unnamedplus" -- Use system clipboard
vim.opt.ignorecase = true -- Ignore case
vim.opt.inccommand = "split" -- Preview for find-replace command
vim.opt.laststatus = 3 -- Global status line
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Relative line numbers
vim.opt.shortmess = "I" -- Disable welcome screen
vim.opt.smartcase = true -- Do not ignore case with capitals
vim.opt.spelllang = "en_us" -- Set default spell language
vim.opt.splitbelow = true -- Put new windows below current
vim.opt.splitright = true -- Put new windows right of current
vim.opt.termguicolors = true -- True color support
vim.opt.tabstop = 4 -- Set tab width to 4 spaces
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true }) -- Reserve space for keymaps

View file

@ -0,0 +1,35 @@
return {
lsp = {
"bashls",
"cssls",
"dockerls",
"eslint",
"golangci_lint_ls",
"gopls",
"graphql",
"jsonls",
"pyright",
"rust_analyzer",
"lua_ls",
"svelte",
"terraformls",
"tsserver",
"yamlls",
},
linter = {
"flake8",
"hadolint",
},
formatter = {
"black",
"goimports",
"prettierd",
"shfmt",
"stylua",
},
dap = {
"delve",
"node-debug2",
"python",
},
}

View file

@ -0,0 +1,11 @@
return {
{
"simrat39/symbols-outline.nvim",
cmd = { "SymbolsOutline" },
keys = {
{ "<Leader>k", "<Cmd>SymbolsOutline<CR>", desc = "Toggle code outline" },
},
config = true,
},
"liuchengxu/vista.vim",
}

View file

@ -0,0 +1,13 @@
return {
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
config = function()
require("tokyonight").setup({
style = "night",
})
vim.api.nvim_command("colorscheme tokyonight")
end,
},
}

View file

@ -0,0 +1,38 @@
return {
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-vsnip",
"hrsh7th/vim-vsnip",
"onsails/lspkind-nvim",
},
config = function()
local cmp = require("cmp")
local sources = {
{ name = "nvim_lua" },
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "buffer" },
}
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = sources,
formatting = { format = require("lspkind").cmp_format() },
})
end,
},
}

View file

@ -0,0 +1,19 @@
return {
-- Automatically set indent settings
{ "tpope/vim-sleuth", event = "VeryLazy" },
-- Edit surrounds
{ "kylechui/nvim-surround", event = "VeryLazy", config = true },
-- Allow to repeat plugin commands
{ "tpope/vim-repeat", event = "VeryLazy" },
-- Autoclose pairs
{ "windwp/nvim-autopairs", event = "InsertEnter", config = true },
-- Toggle comments
{ "numToStr/Comment.nvim", keys = { "gc", { "gc", mode = "v" } }, config = true },
-- Highlight color definitions
{ "NvChad/nvim-colorizer.lua", event = "VeryLazy", config = true },
}

View file

@ -0,0 +1,49 @@
return {
{
"mfussenegger/nvim-dap",
dependencies = {
{ "theHamsta/nvim-dap-virtual-text", config = true },
{
"rcarriga/nvim-dap-ui",
config = function()
local dapui = require("dapui")
dapui.setup()
vim.keymap.set("n", "<Leader>du", dapui.toggle, { desc = "Toggle debugging UI" })
vim.keymap.set("n", "<Leader>dK", function()
dapui.eval(nil, { enter = true })
end, { desc = "Debug symbol under cursor" })
end,
},
},
cmd = { "DapToggleBreakpoint" },
keys = {
{
"<Leader>db",
function()
require("dap").toggle_breakpoint()
end,
desc = "Toggle breakpoint",
},
{
"<Leader>dB",
function()
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
end,
desc = "Set breakpoint condition",
},
},
config = function()
local dap = require("dap")
vim.fn.sign_define("DapBreakpoint", { text = "󰌖", texthl = "", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointCondition", { text = "󰌕", texthl = "", linehl = "", numhl = "" })
vim.keymap.set("n", "<Leader>dd", dap.continue, { desc = "Start/continue debugging" })
vim.keymap.set("n", "<Leader>dn", dap.step_over, { desc = "Step over" })
vim.keymap.set("n", "<Leader>di", dap.step_into, { desc = "Step into" })
vim.keymap.set("n", "<Leader>do", dap.step_out, { desc = "Step out" })
end,
},
}

View file

@ -0,0 +1,10 @@
return {
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
keys = {
{ "<Leader>s", "<Cmd>TroubleToggle workspace_diagnostics<CR>", desc = "Toggle diagnostics" },
},
config = true,
},
}

View file

@ -0,0 +1,10 @@
return {
{
"will133/vim-dirdiff",
cmd = { "DirDiff" },
config = function()
vim.g.DirDiffExcludes =
".DS_Store,.git,.terraform,.gradle,bin,build,coverage,dist,node_modules,target,vendor"
end,
},
}

View file

@ -0,0 +1,25 @@
return {
{
"nvim-tree/nvim-tree.lua",
dependencies = { "nvim-tree/nvim-web-devicons" },
keys = {
{
"<Leader>j",
"<Cmd>NvimTreeFindFileToggle<CR>",
desc = "Toggle file tree",
},
},
opts = {
filters = {
custom = { "^.DS_Store$", "^.git$" },
},
renderer = {
icons = {
show = {
git = false,
},
},
},
},
},
}

View file

@ -0,0 +1,17 @@
return {
{
"folke/zen-mode.nvim",
cmd = { "ZenMode" },
opts = {
window = {
backdrop = 1,
options = {
signcolumn = "no",
number = false,
relativenumber = false,
},
},
},
},
{ "folke/twilight.nvim", config = true, lazy = true },
}

View file

@ -0,0 +1,34 @@
return {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-telescope/telescope-ui-select.nvim",
},
cmd = { "Telescope" },
keys = {
{
"<Leader><space>",
"<Cmd>Telescope find_files find_command=fd,--type=file,--type=symlink,--hidden,--no-ignore,--exclude=.DS_Store,--exclude=.git,--exclude=.terraform,--exclude=.gradle,--exclude=.svelte-kit,--exclude=bin,--exclude=build,--exclude=coverage,--exclude=dist,--exclude=node_modules,--exclude=target,--exclude=vendor,--exclude=venv,--exclude=__pycache__<CR>",
desc = "Find files",
},
{ "<Leader>/", "<Cmd>Telescope live_grep<CR>", desc = "Live grep" },
},
config = function()
local telescope = require("telescope")
telescope.setup({
defaults = {
mappings = {
i = {
["<Esc>"] = require("telescope.actions").close,
},
},
},
})
telescope.load_extension("fzf")
telescope.load_extension("ui-select")
end,
},
}

View file

@ -0,0 +1,61 @@
return {
{
"tpope/vim-fugitive",
cmd = { "Git", "Gread", "Gdiff", "Gvdiffsplit" },
keys = {
{
"<Leader>gg",
":Git<CR>",
desc = "Git status",
},
{
"<Leader>gc",
":Git commit<CR>",
desc = "Git commit",
},
{
"<Leader>gm",
":Git mergetool | Gvdiffsplit!<CR>",
desc = "Git three-way merge",
},
},
},
{
"lewis6991/gitsigns.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
event = "VeryLazy",
keys = {
{
"<Leader>ga",
":Gitsigns stage_hunk<CR>",
desc = "Git add hunk",
},
{
"<Leader>gu",
":Gitsigns undo_stage_hunk<CR>",
desc = "Git unstage hunk",
},
{
"<Leader>gA",
":Gitsigns stage_buffer<CR>",
desc = "Git add file",
},
{
"<Leader>gU",
":Gitsigns reset_buffer<CR>",
desc = "Git reset file",
},
{
"<Leader>gd",
":Gitsigns diffthis<CR>",
desc = "Git diff",
},
{
"<Leader>gb",
":Gitsigns blame_line<CR>",
desc = "Git blame",
},
},
config = true,
},
}

View file

@ -0,0 +1,95 @@
local formatting_group = vim.api.nvim_create_augroup("LspFormatting", { clear = false })
return {
{
"neovim/nvim-lspconfig",
dependencies = { "williamboman/mason-lspconfig.nvim" },
event = "VeryLazy",
config = function()
-- Set correct icons in sign column
local signs = {
Error = "󰅚 ",
Warn = "󰀪 ",
Hint = "󰌶 ",
Info = "󰋽 ",
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl })
end
-- Set up keymaps
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float, { desc = "Show diagnostics of current line" })
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Move to previous diagnostic" })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Move to next diagnostic" })
-- Add additional capabilities supported by nvim-cmp
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local telescope_builtin = require("telescope.builtin")
local function buf_opts(desc)
return { noremap = true, silent = true, buffer = bufnr, desc = desc }
end
vim.keymap.set("n", "K", vim.lsp.buf.hover, buf_opts("Show signature of current symbol"))
vim.keymap.set("n", "gd", telescope_builtin.lsp_definitions, buf_opts("Go to definiton"))
vim.keymap.set("n", "gi", telescope_builtin.lsp_implementations, buf_opts("Go to implementation"))
vim.keymap.set("n", "gr", telescope_builtin.lsp_references, buf_opts("Go to reference"))
vim.keymap.set("n", "<Leader>r", vim.lsp.buf.rename, buf_opts("Rename current symbol"))
vim.keymap.set("n", "<Leader>a", vim.lsp.buf.code_action, buf_opts("Run code action"))
vim.keymap.set("n", "<Leader>f", function()
vim.lsp.buf.format({ async = true })
end, buf_opts("Format current file"))
-- Format on save
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = formatting_group, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = formatting_group,
buffer = bufnr,
callback = function()
vim.lsp.buf.format()
end,
})
end
end
require("mason-lspconfig").setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup({
on_attach = on_attach,
capabilities = capabilities,
})
end,
})
end,
},
{
"jose-elias-alvarez/null-ls.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
event = "VeryLazy",
config = function()
local null_ls = require("null-ls")
null_ls.setup({
-- Sources can be configured in config/tools.lua
-- Format on save
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = formatting_group, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = formatting_group,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ timeout_ms = 5000 })
end,
})
end
end,
})
end,
},
}

View file

@ -0,0 +1,33 @@
return {
{
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local function get_words()
if vim.bo.filetype == "md" or vim.bo.filetype == "txt" or vim.bo.filetype == "markdown" then
if vim.fn.wordcount().visual_words == 1 then
return tostring(vim.fn.wordcount().visual_words) .. " word"
elseif not (vim.fn.wordcount().visual_words == nil) then
return tostring(vim.fn.wordcount().visual_words) .. " words"
else
return tostring(vim.fn.wordcount().words) .. " words"
end
else
return ""
end
end
require("lualine").setup({
sections = {
lualine_a = {},
lualine_x = { "filetype" },
lualine_z = { get_words },
},
extensions = { "nvim-tree" },
options = {
theme = "tokyonight",
},
})
end,
},
}

View file

@ -0,0 +1,66 @@
return {
{
"nvim-neotest/neotest",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"nvim-neotest/neotest-vim-test",
"vim-test/vim-test",
"nvim-neotest/neotest-go",
"haydenmeade/neotest-jest",
"nvim-neotest/neotest-python",
},
keys = {
{
"<Leader>tn",
function()
require("neotest").run.run()
end,
desc = "Run nearest test",
},
{
"<Leader>tf",
function()
require("neotest").run.run(vim.fn.expand("%"))
require("neotest").summary.open()
end,
desc = "Run all tests in file",
},
{
"<Leader>ta",
function()
require("neotest").run.run(vim.fn.getcwd())
require("neotest").summary.open()
end,
desc = "Run all tests in suite",
},
},
config = function()
local neotest = require("neotest")
neotest.setup({
icons = {
failed = "󰅚",
passed = "󰗡",
running = "󰐍",
unknown = "󰘥",
},
adapters = {
require("neotest-go"),
require("neotest-jest"),
require("neotest-python"),
require("neotest-vim-test")({
ignore_filetypes = {
"go",
"python",
},
}),
},
})
vim.keymap.set("n", "<Leader>tu", function()
neotest.summary.toggle()
end, { desc = "Toggle testing UI" })
end,
},
}

View file

@ -0,0 +1,50 @@
local tools = require("config.tools")
return {
{
"williamboman/mason.nvim",
build = ":MasonUpdate",
config = true,
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = { "williamboman/mason.nvim" },
event = "VeryLazy",
opts = {
ensure_installed = tools.lsp,
},
},
{
"jay-babu/mason-null-ls.nvim",
dependencies = { "williamboman/mason.nvim" },
event = { "BufReadPre", "BufNewFile" },
config = function()
local mason_null_ls = require("mason-null-ls")
local null_ls_tools = tools.linter
for _, f in pairs(tools.formatter) do
table.insert(null_ls_tools, f)
end
mason_null_ls.setup({
ensure_installed = null_ls_tools,
handlers = {},
})
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = { "williamboman/mason.nvim" },
event = { "BufReadPre", "BufNewFile" },
opts = {
ensure_installed = tools.dap,
handlers = {},
},
},
{
"RubixDev/mason-update-all",
dependencies = { "williamboman/mason.nvim" },
cmd = { "MasonUpdateAll" },
config = true,
},
}

View file

@ -0,0 +1,42 @@
return {
{
"nvim-treesitter/nvim-treesitter",
build = function()
pcall(require("nvim-treesitter.install").update({ with_sync = true }))
end,
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = "all",
highlight = { enable = true },
})
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
event = "VeryLazy",
config = function()
require("nvim-treesitter.configs").setup({
textobjects = {
select = {
enable = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
},
})
end,
},
{
"nvim-treesitter/nvim-treesitter-context",
dependencies = { "nvim-treesitter/nvim-treesitter" },
event = "VeryLazy",
config = true,
},
}