Add nvim config

This commit is contained in:
Marko Korhonen 2024-09-16 20:40:42 +03:00
parent b227b7cb19
commit 25a48b5694
48 changed files with 1550 additions and 2 deletions

View file

@ -0,0 +1,12 @@
-- Highlight yanked text
local ag = vim.api.nvim_create_augroup
local au = vim.api.nvim_create_autocmd
au('TextYankPost', {
group = ag('yank_highlight', {}),
pattern = '*',
callback = function()
vim.highlight.on_yank { higroup='IncSearch', timeout=300 }
end,
})

View file

@ -0,0 +1,15 @@
vim.keymap.set("n", "<leader>b", function()
local current_theme = vim.fn.eval("&background")
if current_theme == "dark" then
vim.cmd("set background=light")
else
vim.cmd("set background=dark")
end
end, { desc = "Toggle background between dark and light" })
vim.keymap.set("n", "<leader>h", "<cmd>nohlsearch<cr>", { desc = "Turn off search highlight" })
vim.keymap.set("n", "<leader>co", '<cmd>silent! execute "%bd|e#|bd#"<cr>', { desc = "Close other buffers" })
vim.keymap.set("n", "<leader>a", "<cmd>e#<cr>", { desc = "Edit alternate file" })
vim.keymap.set("n", "<Tab>", "<cmd>bnext<cr>", { desc = "Next buffer" })
vim.keymap.set("n", "<S-Tab>", "<cmd>bprevious<cr>", { desc = "Previous buffer" })
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal insert mode with esc" })

View file

@ -0,0 +1,56 @@
-- This module contains lsp related
-- reusable functions
local m = {}
local lsp = vim.lsp
local diagnostic = vim.diagnostic
local k = vim.keymap.set
-- Maps LSP specific keybinds.
-- This makes them only available when LSP is running
function m.map_keys()
local builtin = require("telescope.builtin")
require("which-key").add({
{ "<leader>w", group = "Workspace" },
})
k("n", "<leader>F", lsp.buf.format, { desc = "Format with LSP" })
k("n", "<leader>ca", lsp.buf.code_action, { desc = "Code action" })
k("n", "<leader>e", diagnostic.open_float, { desc = "Open diagnostics" })
k("n", "<leader>k", lsp.buf.signature_help, { desc = "Signature help" })
k("n", "<leader>rn", lsp.buf.rename, { desc = "Rename symbol" })
k("n", "<leader>wa", lsp.buf.add_workspace_folder, { desc = "Add folder" })
k("n", "<leader>wl", function()
print(vim.inspect(lsp.buf.list_workspace_folders()))
end, { desc = "List folders" })
k("n", "<leader>wr", lsp.buf.remove_workspace_folder, { desc = "Remove folder" })
k("n", "K", lsp.buf.hover, { desc = "Hover" })
k("n", "[d", diagnostic.goto_prev, { desc = "Previous diagnostic" })
k("n", "]d", diagnostic.goto_next, { desc = "Next diagnostic" })
k("n", "gD", lsp.buf.declaration, { desc = "Declaration" })
k("n", "gd", builtin.lsp_definitions, { desc = "Definition" })
k("n", "gi", builtin.lsp_implementations, { desc = "Implementation" })
k("n", "gr", builtin.lsp_references, { desc = "References" })
k("n", "gs", builtin.lsp_document_symbols, { desc = "Symbols" })
k("n", "gt", lsp.buf.type_definition, { desc = "Type definition" })
end
-- Combine built-in LSP and cmp cabaibilities
-- and additional capabilities from other plugins
function m.get_capabilities()
local capabilities = vim.tbl_deep_extend(
"force",
lsp.protocol.make_client_capabilities(),
require("cmp_nvim_lsp").default_capabilities()
)
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually for ufo
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
return capabilities
end
return m

View file

@ -0,0 +1,29 @@
local g = vim.g
local o = vim.o
-- Change scale factor with C+ and C-
g.neovide_scale_factor = 1.0
local change_scale_factor = function(delta)
g.neovide_scale_factor = g.neovide_scale_factor * delta
end
vim.keymap.set("n", "<C-+>", function()
change_scale_factor(1.25)
end)
vim.keymap.set("n", "<C-->", function()
change_scale_factor(1 / 1.25)
end)
-- Hide mouse when typing in neovide (disabled)
g.neovide_hide_mouse_when_typing = false
-- Enable cursor particles in neovide
g.neovide_cursor_vfx_mode = "railgun"
-- Enable dark/light theme detection
g.neovide_theme = "auto"
-- Confirm quit
g.neovide_confirm_quit = true
-- Set font
--o.guifont = "Hack Nerd Font Mono:h15"

View file

@ -0,0 +1,2 @@
-- Settings for pager mode
vim.keymap.set("n", "q", vim.cmd.q)

View file

@ -0,0 +1,39 @@
-- Startup dashboard
--- @type LazyPluginSpec
return {
"goolord/alpha-nvim",
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = {
[[ __ ]],
[[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
[[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
[[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
[[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
[[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
}
dashboard.section.buttons.val = {
dashboard.button(
"<leader>p",
"📽 Open a project",
":lua require('telescope').extensions.project.project()<CR>"
),
dashboard.button("e", " New file", ":ene <BAR> startinsert <CR>"),
dashboard.button("<C-f>", "🔍 Find file", "<cmd>Telescope find_files<CR>"),
dashboard.button("<C-g>", "𑪢 Grep files", "<cmd>Telescope live_grep<CR>"),
dashboard.button("l", "🛋 Lazy", ":Lazy<CR>"),
dashboard.button("m", "📦 Mason", ":Mason<CR>"),
dashboard.button("q", "ꭙ Quit NeoVim", ":qa<CR>"),
}
-- Fortune in footer
dashboard.section.footer.val = require("alpha.fortune")()
dashboard.config.opts.noautocmd = true
vim.cmd([[autocmd User AlphaReady echo 'ready']])
alpha.setup(dashboard.config)
end,
}

View file

@ -0,0 +1,15 @@
-- AsciiDoc plugins are grouped together here
return {
-- Vim ♥️ Asciidoctor
--- @type LazyPluginSpec
{
"habamax/vim-asciidoctor",
ft = { "asciidoctor", "asciidoc" },
},
-- AsciiDoc preview
--- @type LazyPluginSpec
{
"tigion/nvim-asciidoc-preview",
ft = { "asciidoctor", "asciidoc" },
},
}

View file

@ -0,0 +1,6 @@
-- Automatic brackets
--- @type LazyPluginSpec
return {
"windwp/nvim-autopairs",
config = true
}

View file

@ -0,0 +1,16 @@
-- Bufferline
--- @type LazyPluginSpec
return {
"akinsho/bufferline.nvim",
dependencies = { "kyazdani42/nvim-web-devicons" },
--- @type BufferlineConfig
opts = {
options = {
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level)
local icon = level:match("error") and "" or ""
return " " .. icon .. count
end,
},
},
}

View file

@ -0,0 +1,6 @@
-- Caddyfile syntax support
--- @type LazyPluginSpec
return {
"isobit/vim-caddyfile",
ft = "caddyfile",
}

View file

@ -0,0 +1,150 @@
-- Auto completion
--- @type LazyPluginSpec
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-buffer", -- Buffer source
-- Git source
{
"petertriho/cmp-git",
dependencies = { "nvim-lua/plenary.nvim" },
config = true,
},
"hrsh7th/cmp-nvim-lsp", -- LSP source
"hrsh7th/cmp-nvim-lua", -- Neovim Lua API documentation source
"hrsh7th/cmp-path", -- Path source
"hrsh7th/cmp-cmdline", -- cmdline source
"saadparwaiz1/cmp_luasnip", -- Snippets source
"f3fora/cmp-spell", -- Spell check source
"petertriho/cmp-git", -- Git source
-- Copilot source
{
"zbirenbaum/copilot-cmp",
opts = { fix_pairs = true },
},
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
-- Set completeopt to have a better completion experience
vim.o.completeopt = "menuone,noselect"
local bordered = cmp.config.window.bordered()
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = bordered,
documentation = bordered,
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-u>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
-- Snippet placeholder forward
["<C-f>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
-- Snippet placeholder backward
["<C-b>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
-- Completion menu forward
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
-- If only one entry, select it
if #cmp.get_entries() == 1 then
cmp.confirm({ select = true })
else
cmp.select_next_item()
end
elseif has_words_before() then
cmp.complete()
if #cmp.get_entries() == 1 then
cmp.confirm({ select = true })
end
else
fallback()
end
end, { "i", "s" }),
-- Completion menu backward
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "git" },
{ name = "copilot" },
{ name = "buffer" },
{ name = "spell" },
{ name = "path" },
{
name = "lazydev",
group_index = 0, -- set group index to 0 to skip loading LuaLS completions
},
},
})
require("cmp_git").setup()
-- Enable autopairs when enter is processed
-- on completion
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
-- search cmdline setup.
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
-- `:` cmdline setup.
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" },
},
},
}),
})
end,
}

View file

@ -0,0 +1,10 @@
-- Confirm before quit
--- @type LazyPluginSpec
return {
cond = vim.g.neovide == not nil,
"yutkat/confirm-quit.nvim",
event = "CmdlineEnter",
opts = {
quit_message = "You are in Neovide, are you sure you want to quit?",
},
}

View file

@ -0,0 +1,9 @@
-- GitHub Copilot
--- @type LazyPluginSpec
return {
"zbirenbaum/copilot.lua",
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
},
}

View file

@ -0,0 +1,3 @@
-- Improved diffs
--- @type LazyPluginSpec
return { "sindrets/diffview.nvim" }

View file

@ -0,0 +1,6 @@
-- Show the current LSP context in winbar
--- @type LazyPluginSpec
return {
enabled = vim.fn.has("nvim-0.10") == 1,
"Bekaboo/dropbar.nvim",
}

View file

@ -0,0 +1,17 @@
-- Neovim inside Firefox
--- @type LazyPluginSpec
return {
"glacambre/firenvim",
build = function()
vim.fn["firenvim#install"](0)
end,
config = function()
vim.g.firenvim_config = {
localSettings = {
[".*"] = {
takeOver = "never",
},
},
}
end,
}

View file

@ -0,0 +1,12 @@
-- Git commands
--- @type LazyPluginSpec
return {
"tpope/vim-fugitive",
dependencies = { "borissov/fugitive-gitea" },
config = function()
vim.g.fugitive_gitea_domains = {
"https://git.korhonen.cc",
"https://git.rossum.fi",
}
end,
}

View file

@ -0,0 +1,34 @@
local k = vim.keymap.set
--- @type LazyPluginSpec
return {
"lewis6991/gitsigns.nvim",
config = function()
local gs = require("gitsigns")
gs.setup()
-- Add groups for which-key
require("which-key").add({
{ "<leader>g", group = "Git" },
{ "<leader>gr", group = "Reset" },
{ "<leader>ga", group = "Add" },
})
-- Keybinds
local opts
-- Hunk navigation
k("n", "[h", gs.prev_hunk, { desc = "Previous hunk" })
k("n", "]h", gs.next_hunk, { desc = "Next hunk" })
-- Hunk actions
opts = { desc = "Hunk" }
k("n", "<leader>grh", gs.reset_hunk, opts)
k("n", "<leader>gah", gs.stage_hunk, opts)
-- Buffer actions
opts = { desc = "Buffer" }
k("n", "<leader>gab", gs.stage_buffer, opts)
k("n", "<leader>grb", gs.reset_buffer, opts)
end,
}

View file

@ -0,0 +1,6 @@
-- Edit GPG encrypted files transparently
--- @type LazyPluginSpec
return {
"jamessan/vim-gnupg",
ft = { "gpg" },
}

View file

@ -0,0 +1,24 @@
-- Indent characters
--- @type LazyPluginSpec
return {
"lukas-reineke/indent-blankline.nvim",
--- @type ibl.config
opts = {
exclude = {
filetypes = {
"",
"checkhealth",
"alpha",
"git",
"gitcommit",
"TelescopePrompt",
"TelescopeResults",
"help",
"lazy",
"lspinfo",
"man",
},
},
},
main = "ibl",
}

View file

@ -0,0 +1,56 @@
-- Colorscheme
--- @type LazyPluginSpec
return {
"rebelot/kanagawa.nvim",
dependencies = { { "f-person/auto-dark-mode.nvim", config = true } },
--- @type KanagawaConfig
opts = {
compile = true,
dimInactive = true,
colors = {
theme = {
all = {
ui = {
bg_gutter = "none", -- Hide gutter background
},
},
},
},
background = {
dark = "wave",
light = "lotus",
},
overrides = function(colors)
local theme = colors.theme
return {
-- Transparent floating windows
NormalFloat = { bg = "none" },
FloatBorder = { bg = "none" },
FloatTitle = { bg = "none" },
NormalDark = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 },
LazyNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim },
MasonNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim },
-- Block-like modern Telescope UI
TelescopeTitle = { fg = theme.ui.special, bold = true },
TelescopePromptNormal = { bg = theme.ui.bg_p1 },
TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 },
TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 },
TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 },
TelescopePreviewNormal = { bg = theme.ui.bg_dim },
TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim },
-- More uniform look for the popup menu
Pmenu = { fg = theme.ui.shade0, bg = theme.ui.bg_p1, blend = vim.o.pumblend },
PmenuSel = { fg = "NONE", bg = theme.ui.bg_p2 },
PmenuSbar = { bg = theme.ui.bg_m1 },
PmenuThumb = { bg = theme.ui.bg_p2 },
}
end,
},
--- @param opts KanagawaConfig
config = function(_, opts)
require("kanagawa").setup(opts)
vim.cmd("colorscheme kanagawa")
end,
}

View file

@ -0,0 +1,15 @@
-- Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.
--- @type LazyPluginSpec
return {
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "luvit-meta/library", words = { "vim%.uv" } },
},
},
},
}

View file

@ -0,0 +1,38 @@
local noice_mode = require("noice").api.statusline.mode
-- Statusline
--- @type LazyPluginSpec
return {
"nvim-lualine/lualine.nvim",
dependencies = { "kyazdani42/nvim-web-devicons" },
opts = {
sections = {
lualine_x = {
"encoding",
"fileformat",
"filetype",
{
noice_mode.get,
cond = noice_mode.has,
color = { fg = "#ff9e64" },
},
},
lualine_z = {
{
"selectioncount",
cond = function()
local mode = vim.fn.mode()
return mode == "v" or mode == "V" or mode == "\22"
end,
},
{
"location",
cond = function()
local mode = vim.fn.mode()
return mode ~= "v" and mode ~= "V" and mode ~= "\22"
end,
},
},
},
},
config = true,
}

View file

@ -0,0 +1,19 @@
-- Snippets plugin
--- @type LazyPluginSpec
return {
"L3MON4D3/LuaSnip",
-- Snippets collection
dependencies = { "rafamadriz/friendly-snippets" },
config = function()
local vsCodeLoader = require("luasnip/loaders/from_vscode")
-- Load friendly-snippets
vsCodeLoader.lazy_load()
-- Load my custom snippets
vsCodeLoader.lazy_load({
paths = { "./snippets" },
})
end,
run = "make install_jsregexp",
}

View file

@ -0,0 +1,10 @@
-- Markdown preview
--- @type LazyPluginSpec
return {
"iamcco/markdown-preview.nvim",
build = "cd app && yarn install",
config = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
}

View file

@ -0,0 +1,60 @@
-- Package manager for LSP servers, DAP adapters etc.
-- It also handles starting all of my LSP servers
--- @type LazyPluginSpec
return {
"williamboman/mason.nvim",
dependencies = {
"neovim/nvim-lspconfig",
"williamboman/mason-lspconfig.nvim",
-- Add MasonUpdateAll
{ "Zeioth/mason-extra-cmds", opts = {} },
-- Add lockfile support
{
"zapling/mason-lock.nvim",
opts = {
lockfile_path = vim.fn.expand("~/git/dotfiles/home/.config/nvim/mason-lock.json"),
},
},
-- Extended functionality for jdtls
"mfussenegger/nvim-jdtls",
-- Add support for LSP file operations
{ "antosha417/nvim-lsp-file-operations", opts = {} },
},
config = function()
require("mason").setup()
local mlspc = require("mason-lspconfig")
local lsp_utils = require("lsp_utils")
local commonLspConfigArgs = {
on_attach = lsp_utils.map_keys,
capabilities = lsp_utils.get_capabilities(),
}
mlspc.setup()
mlspc.setup_handlers({
-- Default handler
function(server_name)
require("lspconfig")[server_name].setup(commonLspConfigArgs)
end,
-- Disable tsserver diagnostics diagnostics
-- that come from ESLint
["tsserver"] = function()
require("lspconfig").tsserver.setup(vim.tbl_extend("force", commonLspConfigArgs, {
settings = {
diagnostics = {
ignoredCodes = {
6133, -- Unused variable
6192, -- Unused import
},
},
},
}))
end,
-- Don't set up jdtls, it is set up by nvim-jdtls
["jdtls"] = function() end,
})
end,
}

View file

@ -0,0 +1,12 @@
-- Library of 30+ independent Lua modules improving overall Neovim
--- @type LazyPluginSpec
return {
"echasnovski/mini.nvim",
config = function()
require("mini.surround").setup()
require("mini.comment").setup()
-- Recommended for which-key
require("mini.icons").setup()
end,
}

View file

@ -0,0 +1,12 @@
-- Formatter plugin
--- @type LazyPluginSpec
return {
"sbdchd/neoformat",
keys = {
{
desc = "Format with Neoformat",
"<leader>f",
"<cmd>Neoformat<cr>",
},
},
}

View file

@ -0,0 +1,30 @@
-- Replace much of neovim's default UI
-- with a modern replacement
--- @type LazyPluginSpec
return {
"folke/noice.nvim",
event = "VeryLazy",
dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify" },
--- @type NoiceConfig
opts = {
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
presets = {
-- add a border to hover docs and signature help
lsp_doc_border = true,
},
},
keys = {
{
desc = "Dismiss notifications",
"<leader>d",
"<cmd>NoiceDismiss<cr>",
},
},
}

View file

@ -0,0 +1,6 @@
-- High performance color highlighter
--- @type LazyPluginSpec
return {
"norcalli/nvim-colorizer.lua",
config = true,
}

View file

@ -0,0 +1,123 @@
-- Debug adapter for NeoVim
local masonPkg = vim.fn.stdpath("data") .. "/mason/packages"
--- @type LazyPluginSpec
return {
"mfussenegger/nvim-dap",
dependencies = {
{
"rcarriga/nvim-dap-ui",
dependencies = { "nvim-neotest/nvim-nio" },
config = true,
},
},
config = function()
local dap = require("dap")
local configurations = dap.configurations
local adapters = dap.adapters
local pick_process = require("dap.utils").pick_process
-- Applies all given configurations to the given filetypes
--- @param filetypes string[]
--- @param configs Configuration[]
local function dapConfigure(filetypes, configs)
for _, ft in ipairs(filetypes) do
configurations[ft] = configs
end
end
-- Bash/sh
local bashAdapter = masonPkg .. "/bash-debug-adapter"
local bashExtension = bashAdapter .. "/extension"
adapters.bashdb = {
type = "executable",
command = bashAdapter .. "/bash-debug-adapter",
name = "bashdb",
}
configurations.sh = {
name = "Debug with bashdb",
type = "bashdb",
request = "launch",
showDebugOutput = true,
trace = true,
pathBashdbLib = bashExtension .. "/bashdb_dir",
pathBashdb = bashExtension .. "/bashdb_dir/bashdb",
file = "${file}",
program = "${file}",
cwd = "${workspaceFolder}",
pathCat = "cat",
pathBash = "/bin/bash",
pathMkfifo = "mkfifo",
pathPkill = "pkill",
args = {},
env = {},
terminalKind = "integrated",
}
-- JavaScript/TypeScript in Firefox/Chrome/Node
adapters.libreWolf = {
type = "executable",
command = "node",
args = { masonPkg .. "/firefox-debug-adapter/dist/adapter.bundle.js" },
}
adapters["pwa-node"] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = "node",
args = { masonPkg .. "/js-debug-adapter/js-debug/src/dapDebugServer.js", "8123" },
},
}
--- @type Configuration[]
local browserConfigs = {
{
name = "LibreWolf attach",
type = "libreWolf",
request = "attach",
url = "http://localhost:4000",
webRoot = "${workspaceFolder}",
},
{
name = "Chrome attach",
type = "pwa-chrome",
request = "attach",
cwd = "${workspaceFolder}",
},
}
--- @type Configuration[]
local nodeConfigs = {
{
name = "Node attach",
type = "pwa-node",
request = "attach",
processId = pick_process,
cwd = "${workspaceFolder}",
},
{
name = "Node launch",
type = "pwa-node",
request = "launch",
program = "${file}",
cwd = "${workspaceFolder}",
port = "8123",
},
}
dapConfigure({ "typescriptreact", "javascriptreact" }, browserConfigs)
dapConfigure({ "typescript", "javascript" }, vim.tbl_extend("force", browserConfigs, nodeConfigs))
-- Java
configurations.java = {
{
name = "Debug (Attach) - Remote",
type = "java",
request = "attach",
hostName = "127.0.0.1",
port = 9009,
},
}
end,
}

View file

@ -0,0 +1,25 @@
-- Tree explorer
--- @type LazyPluginSpec
return {
"kyazdani42/nvim-tree.lua",
dependencies = { "kyazdani42/nvim-web-devicons" },
opts = {
diagnostics = {
enable = true,
show_on_dirs = true,
},
renderer = {
highlight_git = true,
},
update_focused_file = {
enable = true,
},
},
keys = {
{
desc = "Open/close nvim-tree",
"<leader>o",
"<cmd>NvimTreeToggle<cr>",
},
},
}

View file

@ -0,0 +1,8 @@
-- Make editing passwords safer
--- @type LazyPluginSpec
return {
"https://git.zx2c4.com/password-store",
config = function(plugin)
vim.opt.rtp:append(plugin.dir .. "contrib/vim/redact_pass.vim")
end,
}

View file

@ -0,0 +1,16 @@
-- Customize statuscolumn
--- @type LazyPluginSpec
return {
"luukvbaal/statuscol.nvim",
config = function()
local builtin = require("statuscol.builtin")
require("statuscol").setup({
relculright = true,
segments = {
{ text = { builtin.foldfunc }, click = "v:lua.ScFa" },
{ text = { "%s" }, click = "v:lua.ScSa" },
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
},
})
end,
}

View file

@ -0,0 +1,3 @@
-- Do stuff as sudo
--- @type LazyPluginSpec
return { "lambdalisue/suda.vim" }

View file

@ -0,0 +1,107 @@
--- @type LazyPluginSpec
return {
"nvim-telescope/telescope.nvim",
dependencies = {
-- Internal dependency for telescope
"nvim-lua/plenary.nvim",
-- Use fzf for fuzzy finder
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
},
-- Replace vim built in select with telescope
"nvim-telescope/telescope-ui-select.nvim",
-- cd plugin for telescope
"zane-/cder.nvim",
-- project plugin for telescope
"nvim-telescope/telescope-project.nvim",
},
opts = {
-- Set layout to vertical
defaults = {
layout_strategy = "flex",
layout_config = {
flex = {
flip_columns = 200,
},
},
},
pickers = {
find_files = { find_command = { "fd", "-Ht", "f" } },
lsp_references = { show_line = false },
live_grep = {
additional_args = function()
return { "--hidden" }
end,
},
},
extensions = {
cder = {
previewer_command = "eza "
.. "-a "
.. "--color=always "
.. "-T "
.. "--level=3 "
.. "--icons "
.. "--git-ignore "
.. "--long "
.. "--no-permissions "
.. "--no-user "
.. "--no-filesize "
.. "--git "
.. "--ignore-glob=.git",
dir_command = { "fd", "-Ht", "d", ".", os.getenv("HOME") },
},
},
},
keys = function()
local telescope = require("telescope")
local builtin = require("telescope.builtin")
local extensions = telescope.extensions
return {
{
desc = "Open Telescope",
"t",
function()
builtin.builtin({ include_extensions = true })
end,
},
{
desc = "Change directories",
"cd",
extensions.cder.cder,
},
{
desc = "Find files",
"<C-f>",
builtin.find_files,
},
{
desc = "Grep files",
"<C-g>",
builtin.live_grep,
},
{
desc = "Open a project",
"<leader>p",
extensions.project.project,
},
}
end,
config = function(_, opts)
local telescope = require("telescope")
telescope.setup(opts)
-- Load extensions
telescope.load_extension("fzf")
telescope.load_extension("ui-select")
telescope.load_extension("cder")
telescope.load_extension("project")
telescope.load_extension("notify")
end,
}

View file

@ -0,0 +1,153 @@
return {
-- Improved syntax highlighting, text objects and more
--- @type LazyPluginSpec
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
init = function()
require("nvim-treesitter.install").update({
with_sync = true,
})
end,
--- @type TSConfig
opts = {
highlight = { enable = true },
indent = { enable = true },
ensure_installed = {
"bash",
"css",
"diff",
"dockerfile",
"git_config",
"git_rebase",
"gitattributes",
"gitcommit",
"gitignore",
"html",
"http",
"java",
"javascript",
"jsdoc",
"json",
"json5",
"jsonc",
"latex",
"lua",
"luadoc",
"luap",
"make",
"markdown",
"markdown_inline",
"php",
"python",
"query",
"rasi",
"regex",
"rst",
"scss",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"yaml",
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = {
query = "@function.outer",
desc = "Select outer part of a function",
},
["if"] = {
query = "@function.inner",
desc = "Select inner part of a function",
},
["ac"] = {
query = "@class.outer",
desc = "Select outer part of a class",
},
["ic"] = {
query = "@class.inner",
desc = "Select inner part of a class",
},
["as"] = {
query = "@scope",
query_group = "locals",
desc = "Select language scope",
},
},
},
},
},
--- @param opts TSConfig
config = function(_, opts)
if type(opts.ensure_installed) == "table" then
--- @type table<string, boolean>
local added = {}
opts.ensure_installed = vim.tbl_filter(function(lang)
if added[lang] then
return false
end
added[lang] = true
return true
end, opts.ensure_installed)
end
require("nvim-treesitter.configs").setup(opts)
end,
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
config = function()
-- When in diff mode, we want to use the default
-- vim text objects c & C instead of the treesitter ones.
--- @type table<string,fun(...)>
local move = require("nvim-treesitter.textobjects.move")
local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
--- @type table<string,string>
local config = configs.get_module("textobjects.move")[name]
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end
return fn(q, ...)
end
end
end
end,
},
},
},
-- Automatically add closing tags for HTML and JSX
--- @type LazyPluginSpec
{
"windwp/nvim-ts-autotag",
config = true,
},
}

View file

@ -0,0 +1,28 @@
-- Better folds
--- @type LazyPluginSpec
return {
"kevinhwang91/nvim-ufo",
dependencies = { "kevinhwang91/promise-async" },
--- @type UfoConfig
opts = {
close_fold_kinds_for_ft = {
default = { "imports" },
},
},
--- @param opts UfoConfig
config = function(_, opts)
local ufo = require("ufo")
ufo.setup(opts)
-- Using ufo, we need to remap `zR` and `zM`
vim.keymap.set("n", "zR", ufo.openAllFolds)
vim.keymap.set("n", "zM", ufo.closeAllFolds)
-- Fold settings
local o = vim.o
o.foldcolumn = "1"
o.foldlevel = 99
o.foldlevelstart = 99
o.foldenable = true
end,
}

View file

@ -0,0 +1,20 @@
-- Display possible keybinds
--- @type LazyPluginSpec
return {
"folke/which-key.nvim",
config = function()
require("which-key").add({
{ "<leader>", group = "Leader" },
{ "g", group = "Go to" },
})
end,
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}

View file

@ -0,0 +1,53 @@
local o = vim.o
local g = vim.g
o.pumblend = 10
-- Relative line numbers
o.number = true
o.relativenumber = true
-- True colors
o.termguicolors = true
-- Enable cursorline highlighting
o.cursorline = true
-- Floating window transparency
o.winblend = 10
-- Set window title
o.title = true
o.titlestring = "NeoVim: " .. vim.fn.getcwd()
-- Diff settings
o.diffopt = "filler,internal,algorithm:histogram,indent-heuristic"
-- Allow switching buffers with unsaved changes
o.hidden = true
o.guicursor = table.concat({
"i:ver1", -- Vertical bar cursor in insert mode
"a:blinkon1", -- Blinking cursor in all modes
}, ",")
-- Enable global statusline
o.laststatus = 3
-- Use suda by default
g.suda_smart_edit = 1
-- Case insensitive search
o.ignorecase = true
o.smartcase = true
-- Set leader
g.mapleader = " "
-- Indentation settings
o.tabstop = 4
o.softtabstop = -1
o.expandtab = true
o.shiftwidth = 4
o.smartindent = true
o.showmode = false