This commit is contained in:
Christoph J. Scherr 2024-07-08 21:33:16 +02:00
commit 86b1669242
9 changed files with 238 additions and 155 deletions

1
.gitignore vendored
View File

@ -8,4 +8,3 @@ after
**/.DS_Store
lua/custom/secret
lua/custom/configs/secret
lua/settings/theme.lua

147
init.lua
View File

@ -1,88 +1,86 @@
local opt = vim.opt
local g = vim.g
vim.g.mapleader = ' '
vim.g.maplocalleader = ';'
vim.g.python3_host_prog = '/usr/bin/python3'
g.mapleader = ' '
g.maplocalleader = ';'
g.python3_host_prog = '/usr/bin/python3'
opt.mouse = 'a' -- mouse does annoying things for me if it's not 'a'
opt.signcolumn = 'yes'
opt.clipboard = '' -- don't just use the system clipboard
opt.wrap = false
opt.breakindent = false
opt.spell = false
opt.conceallevel = 2
opt.undofile = true
opt.undolevels = 10000
opt.writebackup = false
opt.history = 5000
opt.shada = { "'1000", '<50', 's10', 'h' }
vim.opt.mouse = 'a' -- mouse does annoying things for me if it's not 'a'
vim.opt.signcolumn = 'yes'
vim.opt.clipboard = '' -- don't just use the system clipboard
vim.opt.wrap = false
vim.opt.breakindent = false
vim.opt.spell = false
vim.opt.conceallevel = 2
vim.opt.concealcursor = 'nc'
vim.opt.undofile = true
vim.opt.undolevels = 10000
vim.opt.writebackup = false
vim.opt.history = 5000
vim.opt.shada = { "'1000", '<50', 's10', 'h' }
vim.g.syntax = true
-- Tabs and Indents
-- ===
opt.textwidth = 80 -- Text width maximum chars before wrapping
opt.tabstop = 4 -- The number of spaces a tab is
opt.shiftwidth = 4 -- Number of spaces to use in auto(indent)
opt.smarttab = true -- Tab insert blanks according to 'shiftwidth'
opt.autoindent = true -- Use same indenting on new lines
opt.smartindent = true -- Smart autoindenting on new lines
opt.shiftround = true -- Round indent to multiple of 'shiftwidth'
vim.opt.textwidth = 80 -- Text width maximum chars before wrapping
vim.opt.tabstop = 4 -- The number of spaces a tab is
vim.opt.shiftwidth = 4 -- Number of spaces to use in auto(indent)
vim.opt.smarttab = true -- Tab insert blanks according to 'shiftwidth'
vim.opt.autoindent = true -- Use same indenting on new lines
vim.opt.smartindent = true -- Smart autoindenting on new lines
vim.opt.shiftround = true -- Round indent to multiple of 'shiftwidth'
-- Timing
-- ===
opt.ttimeout = true
opt.timeoutlen = 500 -- Time out on mappings
opt.ttimeoutlen = 10 -- Time out on key codes
opt.updatetime = 250 -- Idle time to write swap and trigger CursorHold
vim.opt.ttimeout = true
vim.opt.timeoutlen = 500 -- Time out on mappings
vim.opt.ttimeoutlen = 10 -- Time out on key codes
vim.opt.updatetime = 250 -- Idle time to write swap and trigger CursorHold
-- Searching
-- ===
opt.ignorecase = true -- Search ignoring case
opt.smartcase = true -- Keep case when searching with *
opt.infercase = true -- Adjust case in insert completion mode
opt.incsearch = true -- Incremental search
vim.opt.ignorecase = true -- Search ignoring case
vim.opt.smartcase = true -- Keep case when searching with *
vim.opt.infercase = true -- Adjust case in insert completion mode
vim.opt.incsearch = true -- Incremental search
vim.opt.hlsearch = true -- highlight searched stuff
-- Formatting
-- ===
opt.wrap = false -- No wrap by default
opt.linebreak = true -- Break long lines at 'breakat'
opt.breakat = '\\ \\ ;:,!?' -- Long lines break chars
opt.startofline = false -- Cursor in same column for few commands
opt.splitbelow = true -- Splits open bottom right
opt.splitright = true
opt.breakindentopt = { shift = 2, min = 20 }
opt.formatoptions = '' -- see :h fo-table & :h formatoptions
vim.opt.wrap = false -- No wrap by default
vim.opt.linebreak = true -- Break long lines at 'breakat'
vim.opt.breakat = '\\ \\ ;:,!?' -- Long lines break chars
vim.opt.startofline = false -- Cursor in same column for few commands
vim.opt.splitbelow = true -- Splits open bottom right
vim.opt.splitright = true
vim.opt.breakindentopt = { shift = 2, min = 20 }
vim.opt.formatoptions = '' -- see :h fo-table & :h formatoptions
vim.opt.breakindent = true
-- Diff
-- ===
opt.diffopt:append { 'iwhite', 'indent-heuristic', 'algorithm:patience' }
opt.wildmode = 'longest:full,full' -- Command-line completion mode
vim.opt.diffopt:append { 'iwhite', 'indent-heuristic', 'algorithm:patience' }
vim.opt.wildmode = 'longest:full,full' -- Command-line completion mode
-- Folds
-- ===
opt.foldlevel = 10 -- start with all folds open
vim.opt.foldlevel = 10 -- start with all folds open
-- Editor UI
-- ===
vim.o.guifont = 'FiraCode Nerd Font:h15'
opt.termguicolors = true
opt.shortmess = 'xsTOInfFitloCaAs'
opt.showmode = true -- Show mode in cmd window
opt.scrolloff = 10 -- Keep at least n lines above/below
opt.sidescrolloff = 10 -- Keep at least n lines left/right
opt.numberwidth = 2 -- Minimum number of columns to use for the line number
opt.number = true -- Show line numbers
opt.relativenumber = true -- Show relative line numbers
opt.ruler = true -- Default status ruler
opt.showtabline = 1 -- Don't change this, goes back to a vanilla vim default
opt.laststatus = 3 -- Always show laststatus
vim.opt.termguicolors = true
vim.opt.shortmess = 'xsTOInfFitloCaAs'
vim.opt.showmode = true -- Show mode in cmd window
vim.opt.scrolloff = 10 -- Keep at least n lines above/below
vim.opt.sidescrolloff = 10 -- Keep at least n lines left/right
vim.opt.numberwidth = 2 -- Minimum number of columns to use for the line number
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Show relative line numbers
vim.opt.ruler = true -- Default status ruler
vim.opt.showtabline = 1 -- Don't change this, goes back to a vanilla vim default
vim.opt.laststatus = 3 -- Always show laststatus
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
@ -116,31 +114,31 @@ if vim.g.neovide == true then
vim.g.neovide_fullscreen = true
end
opt.helpheight = 0 -- Disable help window resizing
opt.winwidth = 30 -- Minimum width for active window
opt.winminwidth = 1 -- Minimum width for inactive windows
opt.winheight = 1 -- Minimum height for active window
opt.winminheight = 1 -- Minimum height for inactive window
vim.opt.helpheight = 0 -- Disable help window resizing
vim.opt.winwidth = 30 -- Minimum width for active window
vim.opt.winminwidth = 1 -- Minimum width for inactive windows
vim.opt.winheight = 1 -- Minimum height for active window
vim.opt.winminheight = 1 -- Minimum height for inactive window
opt.showcmd = false -- show command in status line
opt.cmdheight = 0
opt.cmdwinheight = 5 -- Command-line lines
opt.equalalways = true -- Resize windows on split or close
opt.colorcolumn = '80' -- Column highlight at textwidth's max character-limit
vim.opt.showcmd = false -- show command in status line
vim.opt.cmdheight = 0
vim.opt.cmdwinheight = 5 -- Command-line lines
vim.opt.equalalways = true -- Resize windows on split or close
vim.opt.colorcolumn = '80' -- Column highlight at textwidth's max character-limit
opt.cursorline = true
opt.cursorlineopt = { 'number', 'screenline' }
vim.opt.cursorline = true
vim.opt.cursorlineopt = { 'number', 'screenline' }
opt.pumheight = 10 -- Maximum number of items to show in the popup menu
opt.pumwidth = 10 -- Minimum width for the popup menu
opt.pumblend = 10 -- Popup blend
vim.opt.pumheight = 10 -- Maximum number of items to show in the popup menu
vim.opt.pumwidth = 10 -- Minimum width for the popup menu
vim.opt.pumblend = 10 -- Popup blend
-- Spelling correction
-- ===
opt.spell = false -- manually enable spell with `set spell` or `<leader>ts`
opt.spelllang = 'en,de_de,'
opt.spellsuggest = 'double,50,timeout:5000'
vim.opt.spell = false -- manually enable spell with `set spell` or `<leader>ts`
vim.opt.spelllang = 'en,de_de,'
vim.opt.spellsuggest = 'double,50,timeout:5000'
-- autocommands
-- ===
@ -175,6 +173,7 @@ end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
require 'custom.maps'
require 'custom.autocmds'
require('lazy').setup({
{ import = 'custom.plugins' },
}, {

29
lua/custom/autocmds.lua Normal file
View File

@ -0,0 +1,29 @@
local augroup = vim.api.nvim_create_augroup('plex_generic_autocmds', {})
-- always use the tex filetype for latex things, as those are most supported by
-- latex language servers.
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'latex',
'plaintex',
},
callback = function()
vim.bo.filetype = 'tex'
end,
})
-- conceallevel is what converts things like **bold** to be displayed as bold
-- without the stars. This is useful, but we might not want it for some
-- filetypes.
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'latex',
'plaintex',
'tex',
},
callback = function()
vim.opt_local.conceallevel = 0
end,
})

View File

@ -59,10 +59,12 @@ vim.keymap.set({ 'n' }, '#', "'", { desc = '[Q]uit the current window' })
-- split windows
vim.keymap.set('n', '<leader>"', '<cmd>vsplit<cr>', { desc = 'Split the window vertically' })
vim.keymap.set('n', '<leader>%', '<cmd>split<cr>', { desc = 'Split the window horizontally' })
vim.keymap.set('n', '<leader>w"', '<cmd>vnew<cr>', { desc = 'Split the window vertically (new buffer)' })
vim.keymap.set('n', '<leader>w%', '<cmd>new<cr>', { desc = 'Split the window horizontally (new buffer)' })
-- window actions
vim.keymap.set('n', '<leader>wbn', '<cmd>enew<cr>', { desc = 'Open a [N]ew [B]uffer' })
vim.keymap.set('n', '<leader>wbc', '<cmd>bw<cr>', { desc = '[C]lose current [B]uffer' }) -- :bd would keep in background
vim.keymap.set('n', '<leader>wbn', '<cmd>enew<cr>', { desc = 'Open a [N]ew buffer' })
vim.keymap.set('n', '<leader>wbc', '<cmd>bw<cr>', { desc = '[C]lose current buffer' }) -- :bd would keep in background
vim.keymap.set('n', '<C-Up>', '<cmd>resize +1<cr>', { desc = 'Resize window' })
vim.keymap.set('n', '<C-Down>', '<cmd>resize -1<cr>', { desc = 'Resize window' })
vim.keymap.set('n', '<C-Left>', '<cmd>vertical resize +1<cr>', { desc = 'Resize window vertically' })
@ -75,6 +77,7 @@ vim.keymap.set('n', '<leader>wn', '<cmd>tabnew<cr>', { desc = 'Open a [N]ew [W]o
vim.keymap.set('n', '<leader>wc', '<cmd>tabclose<cr>', { desc = '[C]lose a [W]orkspace/Tab' })
vim.keymap.set('n', '<leader>wk', '<cmd>tabnext<cr>', { desc = 'Next [W]orkspace/Tab' })
vim.keymap.set('n', '<leader>wj', '<cmd>tabprevious<cr>', { desc = 'Last [W]orkspace/Tab' })
vim.keymap.set('n', '<leader>n', '<cmd>enew<cr>', { desc = '[N]ew Buffer' })
vim.keymap.set('t', '<C-w>', vim.api.nvim_replace_termcodes('<C-\\><C-N>', true, true, true), { desc = 'Leave terminal mode' })
@ -85,6 +88,9 @@ vim.keymap.set('t', '<C-w>', vim.api.nvim_replace_termcodes('<C-\\><C-N>', true,
vim.keymap.set({ 'n', 'v' }, '<leader>y', '"+y', { desc = '[Y]ank to system' })
vim.keymap.set({ 'n', 'v' }, '<leader>Y', '"+Y', { desc = '[Y]ank to system' })
vim.keymap.set({ 'n', 'v' }, '<leader>yy', '"+yy', { desc = '[Y]ank to system' })
-- paste from system clipboard
vim.keymap.set({ 'n', 'v' }, '<leader>p', '"+p', { desc = '[P]aste from system' })
vim.keymap.set({ 't', 'n', 'v' }, '<C-S-v>', '<C-w>"+pi', { desc = 'Paste the system clipboard' })
-- add lines from normal and visual, without insert mode

View File

@ -38,12 +38,12 @@ return {
opts = { use_diagnostic_signs = true },
-- stylua: ignore
keys = {
{ '<leader>rb', "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = 'Document Diagnostics (Trouble)' },
{ '<leader>rr', '<cmd>Trouble diagnostics toggle<cr>', desc = 'Workspace Diagnostics (Trouble)' },
{ '<leader>rq', "<cmd>Trouble qflist toggle<cr>", desc = 'Quickfix List (Trouble)' },
{ '<leader>rl', "<cmd>Trouble loclist toggle<cr>", desc = 'Location List (Trouble)' },
{ '<leader>rd', "<cmd>Trouble symbols<cr>", desc = 'LSP symbols (Trouble)' },
{ '<leader>rt', "<cmd>Trouble todo<cr>", desc = 'Todos (Trouble)' },
{ '<leader>ctb', "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = 'Document Diagnostics (Trouble)' },
{ '<leader>ctr', '<cmd>Trouble diagnostics toggle<cr>', desc = 'Workspace Diagnostics (Trouble)' },
{ '<leader>ctq', "<cmd>Trouble qflist toggle<cr>", desc = 'Quickfix List (Trouble)' },
{ '<leader>ctl', "<cmd>Trouble loclist toggle<cr>", desc = 'Location List (Trouble)' },
{ '<leader>ctd', "<cmd>Trouble symbols<cr>", desc = 'LSP symbols (Trouble)' },
{ '<leader>ctt', "<cmd>Trouble todo<cr>", desc = 'Todos (Trouble)' },
{
'[q',
function()

View File

@ -92,7 +92,7 @@ return {
vim.keymap.set('n', '<localleader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<localleader>fb', builtin.buffers, { desc = '[F]ind existing [B]uffers' })
vim.keymap.set('n', '<localleader>fm', builtin.marks, { desc = '[F]ind book[M]arks' })
vim.keymap.set('n', '<localleader>fd', builtin.diagnostics, { desc = '[F]ind LSP [D]iagnostigs' })
vim.keymap.set('n', '<localleader>fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostigs' })
vim.keymap.set('n', '<localleader>fs', builtin.lsp_dynamic_workspace_symbols, { desc = '[F]ind LSP [S]ymbols' })
-- spelling
@ -118,7 +118,7 @@ return {
end, { desc = '[F]ind [/] in Open Files' })
-- Shortcut for searching your Neovim configuration files
vim.keymap.set('n', '<leader>fnf', function()
vim.keymap.set('n', '<localleader>fnf', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[F]ind [N]eovim [F]iles' })
end,

View File

@ -65,6 +65,30 @@ return {
name = 'kanagawa-wave',
colorscheme = 'kanagawa-wave',
},
{
name = 'zenbones',
colorscheme = 'zenbones',
before = [[
-- It's a major hack from the themery guys that this is a string
vim.opt.background = "dark"
]],
},
{
name = 'tokyobones',
colorscheme = 'tokyobones',
before = [[
-- It's a major hack from the themery guys that this is a string
vim.opt.background = "dark"
]],
},
{
name = 'kanagawabones',
colorscheme = 'kanagawabones',
before = [[
-- It's a major hack from the themery guys that this is a string
vim.opt.background = "dark"
]],
},
-- Light themes
{
name = '==========Light Themes==========',
@ -78,6 +102,14 @@ return {
name = 'kanagawa-lotus',
colorscheme = 'kanagawa-lotus',
},
{
name = 'zenbones',
colorscheme = 'zenbones',
before = [[
-- It's a major hack from the themery guys that this is a string
vim.opt.background = "light"
]],
},
},
themeConfigFile = '~/.config/nvim/lua/settings/theme.lua',
livePreview = true, -- Apply theme while browsing. Default to true.
@ -86,4 +118,5 @@ return {
},
'folke/tokyonight.nvim',
'rebelot/kanagawa.nvim',
{ 'zenbones-theme/zenbones.nvim', dependencies = { 'rktjmp/lush.nvim' } },
}

View File

@ -140,22 +140,7 @@ return {
},
{
'folke/which-key.nvim',
keys = { '<leader>', '<localleader>', '<c-r>', '<c-w>', '"', "'", '`', 'c', 'v', 'g' },
defaults = {
mode = { 'n', 'v' },
[';'] = { name = '+telescope' },
[';f'] = { name = '+find' },
['g'] = { name = '+goto' },
[']'] = { name = '+next' },
['['] = { name = '+prev' },
['<leader>d'] = { name = '+lsp/debug' },
['<leader>r'] = { name = '+diagnostics/quickfix' },
['<leader>c'] = { name = '+code' },
['<leader>g'] = { name = '+git' },
['<leader>t'] = { name = '+toggle/tools' },
['<leader>w'] = { name = '+window/which' },
['<leader>f'] = { name = '+formatting' },
},
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
opts = {
triggers_nowait = {
-- marks
@ -178,8 +163,50 @@ return {
v = { 'j', 'k' },
n = { 'o', 'O' },
},
-- plugins = {
-- marks = true, -- shows a list of your marks on ' and `
-- registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
-- -- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- -- No actual key bindings are created
-- spelling = {
-- enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
-- suggestions = 20, -- how many suggestions should be shown in the list?
-- },
-- presets = {
-- operators = true, -- adds help for operators like d, y, ...
-- motions = true, -- adds help for motions
-- text_objects = true, -- help for text objects triggered after entering an operator
-- windows = true, -- default bindings on <c-w>
-- nav = true, -- misc bindings to work with windows
-- z = true, -- bindings for folds, spelling and others prefixed with z
-- g = true, -- bindings for prefixed with g
-- },
-- },
icons = {
breadcrumb = '»', -- symbol used in the command line area that shows your active key combo
separator = '', -- symbol used between a key and it's label
group = '+', -- symbol prepended to a group
},
},
config = function(opts)
local wk = require 'which-key'
local defaults = {
mode = { 'n', 'v' },
['<localleader>'] = { name = '+select', f = { name = '[F]ind' } },
['g'] = { name = '+goto' },
[']'] = { name = '+next' },
['['] = { name = '+prev' },
['<leader>d'] = { name = '+[D]ebug', w = { name = '[W]indow' }, c = { name = '[C]hange' } },
['<leader>c'] = { name = '+[C]ode/[C]olor', t = { name = '+[T]rouble' } },
['<leader>g'] = { name = '+[G]ood tools' },
['<leader>f'] = { name = '+[F]ormatting' },
['<leader>r'] = { name = '[R]ename' },
['<leader>w'] = { name = '[W]orkspace', b = { name = 'buffer' } },
['<leader>t'] = { name = '[T]oggle', ['🚫'] = 'which_key_ignore' },
}
wk.register(defaults, opts)
end,
},
{
'echasnovski/mini.trailspace',
lazy = false,
@ -233,35 +260,20 @@ return {
})
end,
},
{ -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
config = function() -- This is the function that runs, AFTER loading
require('which-key').setup()
-- Document existing key chains
require('which-key').register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<localleader>f'] = { name = '[F]ind', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
}
-- visual mode
require('which-key').register({
['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })
end,
},
{
'RRethy/vim-illuminate',
lazy = false,
event = { 'BufReadPost', 'BufNewFile' },
opts = {
-- providers: provider used to get references in the buffer, ordered by priority
providers = {
'lsp', -- useless for tex but still used
'treesitter',
'regex',
},
large_file_cutoff = 50000,
delay = 200,
under_cursor = false,
under_cursor = true,
modes_allowlist = { 'n', 'no', 'nt' },
filetypes_denylist = {
'DiffviewFileHistory',
@ -271,36 +283,36 @@ return {
'git',
'minifiles',
'neo-tree',
'NvimTree_1',
'dashboard',
},
},
-- looks weird but is useful: put your cursor on a word and other occurences
-- of the word in your buffer will be highlighted. You can then use
-- '[[' and ']]' to go to the next or previous occurence.
--
-- Try it:
--
-- word #### word ###########
-- ############## word ######
-- #### word #### word word #
--
-- (Does only work if the regex source is currently active, otherwise the
-- references are those your language server or treesitter gives out, so
-- syntax aware)
keys = {
{ ']]', desc = 'Next Reference' },
{ '[[', desc = 'Prev Reference' },
},
config = function(_, opts)
require('illuminate').configure(opts)
local function map(key, dir, buffer)
vim.keymap.set('n', key, function()
require('illuminate')['goto_' .. dir .. '_reference'](false)
end, {
desc = dir:sub(1, 1):upper() .. dir:sub(2) .. ' Reference',
buffer = buffer,
})
end
map(']]', 'next')
map('[[', 'prev')
-- also set it after loading ftplugins, since a lot overwrite [[ and ]]
vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('plex_illuminate', {}),
callback = function()
local buffer = vim.api.nvim_get_current_buf()
map(']]', 'next', buffer)
map('[[', 'prev', buffer)
end,
})
local illuminate = require 'illuminate'
illuminate.configure(opts)
vim.keymap.set('n', '[[', function()
illuminate.goto_prev_reference() -- try putting your cursor on `illuminate`
end, { desc = 'Goto last occurence of current word' })
vim.keymap.set('n', ']]', function()
illuminate.goto_next_reference()
end, { desc = 'Goto next occurence of current word' })
end,
},
{
@ -312,8 +324,6 @@ return {
{ ']t', function() require('todo-comments').jump_next() end, desc = 'Next todo comment' },
{ '[t', function() require('todo-comments').jump_prev() end, desc = 'Previous todo comment' },
{ '<LocalLeader>fdt', '<cmd>TodoTelescope<CR>', desc = 'todo' },
{ '<leader>xt', '<cmd>TodoTrouble<CR>', desc = 'Todo (Trouble)' },
{ '<leader>xT', '<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>', desc = 'Todo/Fix/Fixme (Trouble)' },
},
opts = {
signs = true,

7
lua/settings/theme.lua Normal file
View File

@ -0,0 +1,7 @@
-- Use `git update-index --assume-unchanged <file>` to ignore changes in this file
--
-- Themery block
-- This block will be replaced by Themery.
vim.cmd("colorscheme tokyonight-storm")
vim.g.theme_id = 10
-- end themery block