first version, bunch of plugins, keymaps and configuration

This commit is contained in:
Noah Håkansson 2024-01-29 10:08:59 +01:00
parent 2510c29d62
commit ec6733a0ea
30 changed files with 1425 additions and 96 deletions

39
lua/custom/keymaps.lua Normal file
View file

@ -0,0 +1,39 @@
--
-- Additional keymaps
--
local wk = require('which-key')
-- basic navigation
wk.register({
['<leader>w'] = { name = '<C-w>', _ = 'which_key_ignore' },
})
vim.keymap.set('n', '<leader>wh', '<C-w>h', { noremap = true, silent = true, desc = 'move to left window' })
vim.keymap.set('n', '<leader>wj', '<C-w>j', { noremap = true, silent = true, desc = 'move to bottom window' })
vim.keymap.set('n', '<leader>wk', '<C-w>k', { noremap = true, silent = true, desc = 'move to top window' })
vim.keymap.set('n', '<leader>wl', '<C-w>l', { noremap = true, silent = true, desc = 'move to right window' })
vim.keymap.set('n', '<leader>ws', '<C-w>s', { noremap = true, silent = true, desc = 'split window horizontally' })
vim.keymap.set('n', '<leader>wv', '<C-w>v', { noremap = true, silent = true, desc = 'split window vertically' })
vim.keymap.set('n', '<leader>wc', '<C-w>c', { noremap = true, silent = true, desc = 'close window' })
vim.keymap.set('n', '<leader>wq', '<C-w>q', { noremap = true, silent = true, desc = 'quit window' })
vim.keymap.set('n', '<leader>wo', '<C-w>o', { noremap = true, silent = true, desc = 'close all other windows' })
vim.keymap.set('n', '<leader>ww', '<C-w>w', { noremap = true, silent = true, desc = 'move to next window' })
vim.keymap.set('n', '<leader>w+', '<C-w>+', { noremap = true, silent = true, desc = 'increase window height' })
vim.keymap.set('n', '<leader>w-', '<C-w>-', { noremap = true, silent = true, desc = 'decrease window height' })
vim.keymap.set('n', '<leader>w>', '<C-w>>', { noremap = true, silent = true, desc = 'increase window width' })
vim.keymap.set('n', '<leader>w<', '<C-w><', { noremap = true, silent = true, desc = 'decrease window width' })
vim.keymap.set('n', '<leader>w=', '<C-w>=', { noremap = true, silent = true, desc = 'balance window sizes' })
-- Turn off highlight when pressing Esc
vim.keymap.set('n', '<Esc>', '<cmd>noh <CR>', { noremap = false, silent = true })
-- fugitive
vim.keymap.set('n', '<leader>gg', '<cmd>G<cr>', { desc = 'fugitive' })
-- magical base64 encoding/decoding
vim.keymap.set('n', '<M-e>', 'viWy:let @"=system("openssl base64 -A", @")<cr>gv""P', { noremap = true, silent = true })
vim.keymap.set('n', '<M-d>', 'viWy:let @"=system("openssl base64 -A -d", @")<cr>gv""P', { noremap = true, silent = true })
-- Center next/previous search
vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, silent = true })
vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true, silent = true })

5
lua/custom/options.lua Normal file
View file

@ -0,0 +1,5 @@
--
-- Additional options
--
vim.o.cursorline = true

View file

@ -0,0 +1,12 @@
return {
'windwp/nvim-autopairs',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup({})
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}

View file

@ -0,0 +1,38 @@
local M = {
'kevinhwang91/nvim-bqf',
event = 'VeryLazy',
}
function M.config()
require('bqf').setup({
auto_enable = true,
magic_window = true,
auto_resize_height = false,
preview = {
auto_preview = true,
show_title = true,
delay_syntax = 50,
wrap = false,
},
func_map = {
tab = 't',
openc = 'o',
drop = 'O',
split = 's',
vsplit = 'v',
stoggleup = 'M',
stoggledown = 'm',
stogglevm = 'm',
filterr = 'f',
filter = 'F',
prevhist = '<',
nexthist = '>',
sclear = 'c',
ptoggleitem = 'p',
ptoggleauto = 'a',
ptogglemode = 'P',
},
})
end
return M

View file

@ -0,0 +1,12 @@
local M = {
"LunarVim/breadcrumbs.nvim",
dependencies = {
{ "SmiteshP/nvim-navic" },
},
}
function M.config()
require("breadcrumbs").setup()
end
return M

View file

@ -0,0 +1,37 @@
local M = {
'NvChad/nvim-colorizer.lua',
lazy = true,
event = 'VeryLazy',
}
function M.config()
require('colorizer').setup({
filetypes = { '*' },
user_default_options = {
RGB = true, -- #RGB hex codes #ABC
RRGGBB = true, -- #RRGGBB hex codes #777AAA
names = true, -- "Name" codes like Blue or blue
RRGGBBAA = false, -- #RRGGBBAA hex codes
AARRGGBB = false, -- 0xAARRGGBB hex codes
rgb_fn = true, -- CSS rgb() and rgba() functions
hsl_fn = true, -- CSS hsl() and hsla() functions
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
-- Available modes for `mode`: foreground, background, virtualtext
mode = 'background', -- Set the display mode.
-- Available methods are false / true / "normal" / "lsp" / "both"
-- True is same as normal
tailwind = true, -- Enable tailwind colors
-- parsers can contain values used in |user_default_options|
sass = { enable = false, parsers = { 'css' } }, -- Enable sass colors
virtualtext = '',
-- update color values even if buffer is not focused
-- example use: cmp_menu, cmp_docs
always_update = false,
},
-- all the sub-options of filetypes apply to buftypes
buftypes = {},
})
end
return M

View file

@ -0,0 +1,29 @@
--
-- copilot setup config
--
local M = {
'zbirenbaum/copilot.lua',
event = 'BufRead',
}
-- Copilot setup
function M.config()
require('copilot').setup({
suggestion = {
enabled = true,
auto_trigger = true,
debounce = 50,
keymap = {
accept = '<M-a>',
accept_word = '<M-w>',
accept_line = '<M-b>',
next = '<c-j>',
prev = '<c-k>',
dismiss = '<C-d>',
},
},
})
end
return M

View file

@ -0,0 +1,10 @@
local M = {
'nvim-tree/nvim-web-devicons',
event = 'VeryLazy',
}
function M.config()
require('nvim-web-devicons')
end
return M

View file

@ -0,0 +1,76 @@
--
-- dial.nvim
-- A plugin for incrementing and decrementing numbers, dates and switching booleans in Neovim.
--
local M = { 'monaqa/dial.nvim', event = 'VeryLazy' }
function M.config()
local status_ok, dial_config = pcall(require, 'dial.config')
if not status_ok then
return
end
local augend = require('dial.augend')
dial_config.augends:register_group({
default = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias['%Y/%m/%d'],
},
typescript = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.constant.new({ elements = { 'let', 'const' } }),
},
visual = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias['%Y/%m/%d'],
augend.constant.alias.alpha,
augend.constant.alias.Alpha,
},
mygroup = {
augend.constant.new({
elements = { 'and', 'or' },
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
cyclic = true, -- "or" is incremented into "and".
}),
augend.constant.new({
elements = { 'True', 'False' },
word = true,
cyclic = true,
}),
augend.constant.new({
elements = { 'public', 'private' },
word = true,
cyclic = true,
}),
augend.constant.new({
elements = { 'sad', 'sad' },
word = true,
cyclic = true,
}),
augend.constant.new({
elements = { '&&', '||' },
word = false,
cyclic = true,
}),
augend.date.alias['%m/%d/%Y'], -- date (02/01/2022, etc.)
augend.constant.alias.bool, -- boolean value (true <-> false)
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.semver.alias.semver,
},
})
local map = require('dial.map')
-- change augends in VISUAL mode
vim.api.nvim_set_keymap('n', '<C-a>', map.inc_normal('mygroup'), { noremap = true })
vim.api.nvim_set_keymap('n', '<C-x>', map.dec_normal('mygroup'), { noremap = true })
vim.api.nvim_set_keymap('v', '<C-a>', map.inc_normal('visual'), { noremap = true })
vim.api.nvim_set_keymap('v', '<C-x>', map.dec_normal('visual'), { noremap = true })
end
return M

View file

@ -0,0 +1,97 @@
local M = {
'stevearc/dressing.nvim',
event = 'VeryLazy',
}
function M.config()
require('dressing').setup({
input = {
-- Set to false to disable the vim.ui.input implementation
enabled = true,
-- Default prompt string
default_prompt = 'Input:',
-- Can be 'left', 'right', or 'center'
title_pos = 'left',
-- When true, <Esc> will close the modal
insert_only = false,
-- When true, input will start in insert mode.
start_in_insert = true,
-- These are passed to nvim_open_win
border = 'rounded',
-- 'editor' and 'win' will default to being centered
relative = 'cursor',
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
prefer_width = 40,
width = nil,
-- min_width and max_width can be a list of mixed types.
-- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
max_width = { 140, 0.9 },
min_width = { 40, 0.2 },
buf_options = {},
win_options = {
-- Window transparency (0-100)
winblend = 0,
-- Disable line wrapping
wrap = false,
-- Indicator for when text exceeds window
list = true,
listchars = 'precedes:…,extends:…',
-- Increase this for more context when text scrolls off the window
sidescrolloff = 0,
},
-- Set to `false` to disable
mappings = {
n = {
['<Esc>'] = 'Close',
['<CR>'] = 'Confirm',
},
i = {
['<C-c>'] = 'Close',
['<CR>'] = 'Confirm',
['<Up>'] = 'HistoryPrev',
['<Down>'] = 'HistoryNext',
},
},
override = function(conf)
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
return conf
end,
-- see :help dressing_get_config
get_config = nil,
},
select = {
-- Set to false to disable the vim.ui.select implementation
enabled = true,
-- Priority list of preferred vim.select implementations
backend = { 'telescope', 'fzf_lua', 'fzf', 'builtin', 'nui' },
-- Trim trailing `:` from prompt
trim_prompt = true,
-- Options for telescope selector
-- These are passed into the telescope picker directly. Can be used like:
-- telescope = require('telescope.themes').get_ivy({...})
telescope = nil,
-- Used to override format_item. See :help dressing-format
format_item_override = {},
-- see :help dressing_get_config
get_config = nil,
},
})
end
return M

View file

@ -0,0 +1,13 @@
local M = {
'jinh0/eyeliner.nvim',
event = 'VeryLazy',
}
function M.config()
require('eyeliner').setup({
highlight_on_key = true,
dim = true,
})
end
return M

View file

@ -0,0 +1,21 @@
local M = {
'ThePrimeagen/harpoon',
event = 'VeryLazy',
dependencies = {
{ 'nvim-lua/plenary.nvim' },
},
}
function M.config()
local keymap = vim.keymap.set
local opts = { noremap = true, silent = true }
keymap('n', '<M-a>', "<cmd>lua require('harpoon.mark').add_file()<cr>", opts)
keymap('n', '<M-f>', "<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>", opts)
keymap('n', '<C-h>', "<cmd>lua require('harpoon.ui').nav_file(1)<cr>", opts)
keymap('n', '<C-j>', "<cmd>lua require('harpoon.ui').nav_file(2)<cr>", opts)
keymap('n', '<C-k>', "<cmd>lua require('harpoon.ui').nav_file(3)<cr>", opts)
keymap('n', '<C-l>', "<cmd>lua require('harpoon.ui').nav_file(4)<cr>", opts)
end
return M

View file

@ -0,0 +1,100 @@
local M = {
'RRethy/vim-illuminate',
event = 'VeryLazy',
}
function M.config()
require('illuminate').configure({
-- providers: provider used to get references in the buffer, ordered by priority
providers = {
'lsp',
'treesitter',
'regex',
},
-- delay: delay in milliseconds
delay = 100,
-- filetype_overrides: filetype specific overrides.
-- The keys are strings to represent the filetype while the values are tables that
-- supports the same keys passed to .configure except for filetypes_denylist and filetypes_allowlist
filetype_overrides = {},
-- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist
filetypes_denylist = {
'mason',
'harpoon',
'DressingInput',
'NeogitCommitMessage',
'qf',
'dirvish',
'oil',
'minifiles',
'fugitive',
'alpha',
'NvimTree',
'lazy',
'NeogitStatus',
'Trouble',
'netrw',
'lir',
'DiffviewFiles',
'Outline',
'Jaq',
'spectre_panel',
'toggleterm',
'DressingSelect',
'TelescopePrompt',
},
-- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist
-- You must set filetypes_denylist = {} to override the defaults to allow filetypes_allowlist to take effect
filetypes_allowlist = {},
-- modes_denylist: modes to not illuminate, this overrides modes_allowlist
-- See `:help mode()` for possible values
modes_denylist = {},
-- modes_allowlist: modes to illuminate, this is overridden by modes_denylist
-- See `:help mode()` for possible values
modes_allowlist = {},
-- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist
-- Only applies to the 'regex' provider
-- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
providers_regex_syntax_denylist = {},
-- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist
-- Only applies to the 'regex' provider
-- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
providers_regex_syntax_allowlist = {},
-- under_cursor: whether or not to illuminate under the cursor
under_cursor = true,
-- large_file_cutoff: number of lines at which to use large_file_config
-- The `under_cursor` option is disabled when this cutoff is hit
large_file_cutoff = nil,
-- large_file_config: config to use for large files (based on large_file_cutoff).
-- Supports the same keys passed to .configure
-- If nil, vim-illuminate will be disabled for large files.
large_file_overrides = nil,
-- min_count_to_highlight: minimum number of matches required to perform highlighting
min_count_to_highlight = 1,
-- should_enable: a callback that overrides all other settings to
-- enable/disable illumination. This will be called a lot so don't do
-- anything expensive in it.
should_enable = function(bufnr)
return true
end,
-- case_insensitive_regex: sets regex case sensitivity
case_insensitive_regex = false,
})
end
-- -- change the highlight style
-- vim.api.nvim_set_hl(0, 'IlluminatedWordText', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { link = 'Visual' })
--
-- --- auto update the highlight style on colorscheme change
-- vim.api.nvim_create_autocmd({ 'ColorScheme' }, {
-- pattern = { '*' },
-- callback = function(ev)
-- vim.api.nvim_set_hl(0, 'IlluminatedWordText', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { link = 'Visual' })
-- end,
-- })
return M

View file

@ -0,0 +1,20 @@
local M = {
'SmiteshP/nvim-navic',
}
function M.config()
local icons = require('utils.icons')
require('nvim-navic').setup({
icons = icons.kind,
highlight = true,
lsp = {
auto_attach = true,
},
click = true,
separator = ' ' .. icons.ui.ChevronRight .. ' ',
depth_limit = 0,
depth_limit_indicator = '..',
})
end
return M

View file

@ -0,0 +1,34 @@
local M = {
'nvimtools/none-ls.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
}
function M.config()
local null_ls = require('null-ls')
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local code_actions = null_ls.builtins.code_actions
local completions = null_ls.builtins.completion
null_ls.setup({
debug = false,
sources = {
formatting.stylua,
formatting.black,
formatting.prettier.with({
extra_filetypes = { 'toml' },
-- extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" },
}),
formatting.eslint_d,
diagnostics.eslint_d,
null_ls.builtins.diagnostics.flake8,
-- diagnostics.flake8,
code_actions.eslint_d,
},
})
end
return M

View file

@ -0,0 +1,113 @@
local M = {
'nvim-tree/nvim-tree.lua',
event = 'VeryLazy',
}
local function my_on_attach(bufnr)
local api = require('nvim-tree.api')
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set('n', 'l', api.node.open.edit, opts('Open'))
vim.keymap.set('n', 'o', api.node.open.edit, opts('Open'))
vim.keymap.set('n', '<CR>', api.node.open.edit, opts('Open'))
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split'))
vim.keymap.set('n', 'h', api.node.open.horizontal, opts('Open: Horizontal Split'))
vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory'))
end
function M.config()
local wk = require('which-key')
wk.register({
['<leader>e'] = { '<cmd>NvimTreeToggle<CR>', 'Explorer' },
})
local icons = require('utils.icons')
require('nvim-tree').setup({
hijack_netrw = false,
sync_root_with_cwd = true,
on_attach = my_on_attach,
renderer = {
add_trailing = false,
group_empty = false,
highlight_git = false,
full_name = false,
highlight_opened_files = 'none',
root_folder_label = ':t',
indent_width = 2,
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = '',
edge = '',
item = '',
none = ' ',
},
},
icons = {
git_placement = 'before',
padding = ' ',
symlink_arrow = '',
glyphs = {
default = icons.ui.Text,
symlink = icons.ui.FileSymlink,
bookmark = icons.ui.BookMark,
folder = {
arrow_closed = icons.ui.ChevronRight,
arrow_open = icons.ui.ChevronShortDown,
default = icons.ui.Folder,
open = icons.ui.FolderOpen,
empty = icons.ui.EmptyFolder,
empty_open = icons.ui.EmptyFolderOpen,
symlink = icons.ui.FolderSymlink,
symlink_open = icons.ui.FolderOpen,
},
git = {
unstaged = icons.git.FileUnstaged,
staged = icons.git.FileStaged,
unmerged = icons.git.FileUnmerged,
renamed = icons.git.FileRenamed,
untracked = icons.git.FileUntracked,
deleted = icons.git.FileDeleted,
ignored = icons.git.FileIgnored,
},
},
},
special_files = { 'Cargo.toml', 'Makefile', 'README.md', 'readme.md' },
symlink_destination = true,
},
update_focused_file = {
enable = true,
debounce_delay = 15,
update_root = true,
ignore_list = {},
},
diagnostics = {
enable = true,
show_on_dirs = false,
show_on_open_dirs = true,
debounce_delay = 50,
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR,
},
icons = {
hint = icons.diagnostics.BoldHint,
info = icons.diagnostics.BoldInformation,
warning = icons.diagnostics.BoldWarning,
error = icons.diagnostics.BoldError,
},
},
})
end
return M

View file

@ -0,0 +1,8 @@
local M = {
'b0o/schemastore.nvim',
lazy = true,
}
function M.config() end
return M

View file

@ -0,0 +1,16 @@
local M = {
'gbprod/substitute.nvim',
lazy = true,
event = 'VeryLazy',
}
function M.config()
require('substitute').setup()
end
vim.api.nvim_set_keymap('n', 's', "<cmd>lua require('substitute').operator()<cr>", { noremap = true })
vim.api.nvim_set_keymap('n', 'ss', "<cmd>lua require('substitute').line()<cr>", { noremap = true })
vim.api.nvim_set_keymap('n', 'S', "<cmd>lua require('substitute').eol()<cr>", { noremap = true })
vim.api.nvim_set_keymap('x', 's', "<cmd>lua require('substitute').visual()<cr>", { noremap = true })
return M

View file

@ -0,0 +1,14 @@
local M = {
'kylechui/nvim-surround',
version = '*', -- Use for stability; omit to use `main` branch for the latest features
lazy = true,
event = 'VeryLazy',
}
function M.config()
require('nvim-surround').setup({
-- Configuration here, or leave empty to use defaults
})
end
return M

View file

@ -0,0 +1,37 @@
local M = {
'pmizio/typescript-tools.nvim',
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
opts = {},
}
function M.config()
require('typescript-tools').setup({
settings = {
-- spawn additional tsserver instance to calculate diagnostics on it
separate_diagnostic_server = true,
-- "change"|"insert_leave" determine when the client asks the server about diagnostic
publish_diagnostic_on = 'insert_leave',
-- array of strings("fix_all"|"add_missing_imports"|"remove_unused")
-- specify commands exposed as code_actions
expose_as_code_action = {},
-- string|nil - specify a custom path to `tsserver.js` file, if this is nil or file under path
-- not exists then standard path resolution strategy is applied
tsserver_path = nil,
-- specify a list of plugins to load by tsserver, e.g., for support `styled-components`
-- (see 💅 `styled-components` support section)
tsserver_plugins = {},
-- this value is passed to: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
-- memory limit in megabytes or "auto"(basically no limit)
tsserver_max_memory = 'auto',
-- described below
tsserver_format_options = {},
tsserver_file_preferences = {
-- importModuleSpecifierPreference = "project-relative",
},
-- mirror of VSCode's `typescript.suggest.completeFunctionCalls`
complete_function_calls = false,
},
})
end
return M