Renormalized + itronb adjustments
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
-- define your colorscheme here
|
||||
local colorscheme = 'lunaperche-sl'
|
||||
|
||||
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||
if not is_ok then
|
||||
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
|
||||
return
|
||||
end
|
||||
-- define your colorscheme here
|
||||
local colorscheme = 'lunaperche-sl'
|
||||
|
||||
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||
if not is_ok then
|
||||
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1,109 +1,116 @@
|
||||
local alpha = require 'alpha'
|
||||
local dashboard = require 'alpha.themes.dashboard'
|
||||
|
||||
_Gopts = {
|
||||
position = 'center',
|
||||
hl = 'Type',
|
||||
wrap = 'overflow',
|
||||
}
|
||||
|
||||
-- DASHBOARD HEADER
|
||||
|
||||
local function getGreeting()
|
||||
local tableTime = os.date '*t'
|
||||
local datetime = os.date ' %Y-%m-%d-%A %H:%M:%S '
|
||||
local hour = tableTime.hour
|
||||
local greetingsTable = {
|
||||
[1] = ' Sleep well',
|
||||
[2] = ' Good morning',
|
||||
[3] = ' Good afternoon',
|
||||
[4] = ' Good evening',
|
||||
[5] = ' Good night',
|
||||
}
|
||||
local greetingIndex = 0
|
||||
if hour == 23 or hour < 7 then
|
||||
greetingIndex = 1
|
||||
elseif hour < 12 then
|
||||
greetingIndex = 2
|
||||
elseif hour >= 12 and hour < 18 then
|
||||
greetingIndex = 3
|
||||
elseif hour >= 18 and hour < 21 then
|
||||
greetingIndex = 4
|
||||
elseif hour >= 21 then
|
||||
greetingIndex = 5
|
||||
end
|
||||
return datetime .. ' ' .. greetingsTable[greetingIndex]
|
||||
end
|
||||
|
||||
local logo = [[
|
||||
|
||||
|
||||
████ ██████ █████ ██
|
||||
███████████ █████
|
||||
█████████ ███████████████████ ███ ███████████
|
||||
█████████ ███ █████████████ █████ ██████████████
|
||||
█████████ ██████████ █████████ █████ █████ ████ █████
|
||||
███████████ ███ ███ █████████ █████ █████ ████ █████
|
||||
██████ █████████████████████ ████ █████ █████ ████ ██████
|
||||
|
||||
]]
|
||||
|
||||
local greeting = getGreeting()
|
||||
local marginBottom = 0
|
||||
|
||||
-- Split logo into lines
|
||||
local logoWidth = 0
|
||||
for line in logo:gmatch '[^\n]+' do
|
||||
logoWidth = math.max(logoWidth, #line / 2)
|
||||
end
|
||||
logoWidth = 75 -- code above does not work with utf8 strings in lua 5.1
|
||||
|
||||
-- Calculate padding for centering the greeting
|
||||
local greetingWidth = #greeting - 3
|
||||
local padding = math.floor((logoWidth - greetingWidth) / 2)
|
||||
-- Generate spaces for padding
|
||||
local paddedGreeting = string.rep(' ', padding) .. greeting
|
||||
|
||||
|
||||
local userName = "You work as '" .. vim.env.USER .. "'."
|
||||
|
||||
-- Calculate padding for centering the username
|
||||
local userNameWidth = #userName
|
||||
local padding = math.floor((logoWidth - userNameWidth) / 2)
|
||||
-- Generate spaces for padding
|
||||
local userNamePadded = string.rep(' ', padding) .. userName
|
||||
|
||||
|
||||
-- Add margin lines below the padded greeting
|
||||
local margin = string.rep('\n', marginBottom * 5)
|
||||
|
||||
-- Concatenate logo, padded greeting, and margin
|
||||
local adjustedLogo = logo .. '\n' .. paddedGreeting .. '\n\n' .. userNamePadded .. '\n' .. margin
|
||||
dashboard.section.header.val = vim.split(adjustedLogo, '\n')
|
||||
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button('d', ' Diary Entry', '<cmd>Diary<CR>'),
|
||||
dashboard.button('n', ' New file', ':ene <BAR> startinsert <CR>'),
|
||||
dashboard.button('s', ' Settings', '<cmd>WorkspacesOpen config-nvim<CR>'),
|
||||
dashboard.button('u', ' Update plugins', '<cmd>Lazy update<CR>'),
|
||||
dashboard.button('w', ' Workspaces', '<cmd>WorkspacesOpen<CR>'),
|
||||
dashboard.button('q', ' Quit', '<cmd>qa<CR>'),
|
||||
}
|
||||
|
||||
-- dashboard.section.footer.val = greeting
|
||||
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'LazyVimStarted',
|
||||
desc = 'Add Alpha dashboard footer',
|
||||
once = true,
|
||||
callback = function()
|
||||
local stats = require('lazy').stats()
|
||||
local ms = math.floor(stats.startuptime * 100 + 0.5) / 100
|
||||
dashboard.section.footer.val = { ' ', ' ', ' ', ' Loaded ' .. stats.count .. ' plugins in ' .. ms .. ' ms ' }
|
||||
dashboard.section.header.opts.hl = 'DashboardFooter'
|
||||
pcall(vim.cmd.AlphaRedraw)
|
||||
end,
|
||||
})
|
||||
|
||||
dashboard.opts.opts.noautocmd = true
|
||||
alpha.setup(dashboard.opts)
|
||||
local alpha = require 'alpha'
|
||||
local dashboard = require 'alpha.themes.dashboard'
|
||||
|
||||
_Gopts = {
|
||||
position = 'center',
|
||||
hl = 'Type',
|
||||
wrap = 'overflow',
|
||||
}
|
||||
|
||||
-- DASHBOARD HEADER
|
||||
|
||||
local function getGreeting()
|
||||
local tableTime = os.date '*t'
|
||||
local datetime = os.date ' %Y-%m-%d-%A %H:%M:%S '
|
||||
local hour = tableTime.hour
|
||||
local greetingsTable = {
|
||||
[1] = ' Sleep well',
|
||||
[2] = ' Good morning',
|
||||
[3] = ' Good afternoon',
|
||||
[4] = ' Good evening',
|
||||
[5] = ' Good night',
|
||||
}
|
||||
local greetingIndex = 0
|
||||
if hour == 23 or hour < 7 then
|
||||
greetingIndex = 1
|
||||
elseif hour < 12 then
|
||||
greetingIndex = 2
|
||||
elseif hour >= 12 and hour < 18 then
|
||||
greetingIndex = 3
|
||||
elseif hour >= 18 and hour < 21 then
|
||||
greetingIndex = 4
|
||||
elseif hour >= 21 then
|
||||
greetingIndex = 5
|
||||
end
|
||||
return datetime .. ' ' .. greetingsTable[greetingIndex]
|
||||
end
|
||||
|
||||
local logo = [[
|
||||
|
||||
|
||||
████ ██████ █████ ██
|
||||
███████████ █████
|
||||
█████████ ███████████████████ ███ ███████████
|
||||
█████████ ███ █████████████ █████ ██████████████
|
||||
█████████ ██████████ █████████ █████ █████ ████ █████
|
||||
███████████ ███ ███ █████████ █████ █████ ████ █████
|
||||
██████ █████████████████████ ████ █████ █████ ████ ██████
|
||||
|
||||
]]
|
||||
|
||||
local greeting = getGreeting()
|
||||
local marginBottom = 0
|
||||
|
||||
-- Split logo into lines
|
||||
local logoWidth = 0
|
||||
for line in logo:gmatch '[^\n]+' do
|
||||
logoWidth = math.max(logoWidth, #line / 2)
|
||||
end
|
||||
logoWidth = 75 -- code above does not work with utf8 strings in lua 5.1
|
||||
|
||||
-- Calculate padding for centering the greeting
|
||||
local greetingWidth = #greeting - 3
|
||||
local padding = math.floor((logoWidth - greetingWidth) / 2)
|
||||
-- Generate spaces for padding
|
||||
local paddedGreeting = string.rep(' ', padding) .. greeting
|
||||
|
||||
local userName = "You work as '" .. (vim.env.USER or vim.env.USERNAME) .. "'."
|
||||
|
||||
-- Calculate padding for centering the username
|
||||
local userNameWidth = #userName
|
||||
local padding = math.floor((logoWidth - userNameWidth) / 2)
|
||||
-- Generate spaces for padding
|
||||
local userNamePadded = string.rep(' ', padding) .. userName
|
||||
|
||||
|
||||
-- Add margin lines below the padded greeting
|
||||
local margin = string.rep('\n', marginBottom * 5)
|
||||
|
||||
-- Concatenate logo, padded greeting, and margin
|
||||
local adjustedLogo = logo .. '\n' .. paddedGreeting .. '\n\n' .. userNamePadded .. '\n' .. margin
|
||||
dashboard.section.header.val = vim.split(adjustedLogo, '\n')
|
||||
|
||||
local buttons = {
|
||||
dashboard.button('n', ' New file', ':ene <BAR> startinsert <CR>'),
|
||||
dashboard.button('s', ' Settings', '<cmd>WorkspacesOpen config-nvim<CR>'),
|
||||
dashboard.button('t', '[] Todo List', '<cmd>Org agenda t<CR>'),
|
||||
dashboard.button('u', ' Update plugins', '<cmd>Lazy update<CR>'),
|
||||
dashboard.button('w', ' Workspaces', '<cmd>WorkspacesOpen<CR>'),
|
||||
dashboard.button('q', ' Quit', '<cmd>qa<CR>'),
|
||||
}
|
||||
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
table.insert(buttons, 1,
|
||||
dashboard.button('d', ' Diary Entry', '<cmd>Diary<CR>'))
|
||||
end
|
||||
|
||||
dashboard.section.buttons.val = buttons
|
||||
|
||||
-- dashboard.section.footer.val = greeting
|
||||
|
||||
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'LazyVimStarted',
|
||||
desc = 'Add Alpha dashboard footer',
|
||||
once = true,
|
||||
callback = function()
|
||||
local stats = require('lazy').stats()
|
||||
local ms = math.floor(stats.startuptime * 100 + 0.5) / 100
|
||||
dashboard.section.footer.val = { ' ', ' ', ' ', ' Loaded ' .. stats.count .. ' plugins in ' .. ms .. ' ms ' }
|
||||
dashboard.section.header.opts.hl = 'DashboardFooter'
|
||||
pcall(vim.cmd.AlphaRedraw)
|
||||
end,
|
||||
})
|
||||
|
||||
dashboard.opts.opts.noautocmd = true
|
||||
alpha.setup(dashboard.opts)
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
theme = 'papercolor_light',
|
||||
component_separators = {},
|
||||
section_separators = {},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = { "neo-tree" },
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = {},
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype', 'lsp_status' },
|
||||
lualine_y = { 'filesize' },
|
||||
lualine_z = { 'progress', 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
-- lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_x = {},
|
||||
lualine_y = { 'filesize' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {}, -- formerly breadcrumb here
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
}
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
theme = 'papercolor_light',
|
||||
component_separators = {},
|
||||
section_separators = {},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = { "neo-tree" },
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = {},
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype', 'lsp_status' },
|
||||
lualine_y = { 'filesize' },
|
||||
lualine_z = { 'progress', 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
-- lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_x = {},
|
||||
lualine_y = { 'filesize' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {}, -- formerly breadcrumb here
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
local diary_open = function(opts)
|
||||
local date = opts.args ~= '' and opts.args or os.date('%Y-%m-%d')
|
||||
local year, month = date:match('(%d%d%d%d)-(%d%d)')
|
||||
local folder = vim.fs.joinpath(vim.env.HOME, string.format('.diary/asciidoc/%s', year))
|
||||
vim.fn.mkdir(folder, "p")
|
||||
local file = string.format('%s/diary-%s-%s.adoc', folder, year, month)
|
||||
print("file is:", file)
|
||||
vim.cmd('e ' .. file)
|
||||
vim.cmd('normal! G') -- go to end of file
|
||||
|
||||
-- NOTE.2025-06-08 [1] and [2] should be replaced with snippet name, but I
|
||||
-- don't know how -- neither do grok nor chatgpt ...
|
||||
local snips = require('luasnip')
|
||||
local asnippets = snips.get_snippets('asciidoc')
|
||||
if vim.fn.getfsize(file) == 0 then
|
||||
snips.snip_expand(asnippets[1])
|
||||
vim.cmd('normal! G')
|
||||
end
|
||||
|
||||
vim.cmd('normal! 3o') -- insert some newlines before new entry
|
||||
snips.snip_expand(asnippets[2])
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Diary", diary_open, { nargs = '?' })
|
||||
local diary_open = function(opts)
|
||||
local date = opts.args ~= '' and opts.args or os.date('%Y-%m-%d')
|
||||
local year, month = date:match('(%d%d%d%d)-(%d%d)')
|
||||
local folder = vim.fs.joinpath(vim.env.HOME, string.format('.diary/asciidoc/%s', year))
|
||||
vim.fn.mkdir(folder, "p")
|
||||
local file = string.format('%s/diary-%s-%s.adoc', folder, year, month)
|
||||
print("file is:", file)
|
||||
vim.cmd('e ' .. file)
|
||||
vim.cmd('normal! G') -- go to end of file
|
||||
|
||||
-- NOTE.2025-06-08 [1] and [2] should be replaced with snippet name, but I
|
||||
-- don't know how -- neither do grok nor chatgpt ...
|
||||
local snips = require('luasnip')
|
||||
local asnippets = snips.get_snippets('asciidoc')
|
||||
if vim.fn.getfsize(file) == 0 then
|
||||
snips.snip_expand(asnippets[1])
|
||||
vim.cmd('normal! G')
|
||||
end
|
||||
|
||||
vim.cmd('normal! 3o') -- insert some newlines before new entry
|
||||
snips.snip_expand(asnippets[2])
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Diary", diary_open, { nargs = '?' })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
CON = 'confile',
|
||||
},
|
||||
})
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
CON = 'confile',
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
-- custom defined functions
|
||||
|
||||
-- Return the currently, visually selected text range
|
||||
function SL_get_visual_selection()
|
||||
vim.cmd([[ execute "normal! \<ESC>" ]])
|
||||
local s_start = vim.fn.getcharpos("'<")
|
||||
local s_end = vim.fn.getcharpos("'>")
|
||||
vim.cmd([[ execute "normal! gv" ]])
|
||||
|
||||
local current_buffer = vim.api.nvim_get_current_buf()
|
||||
local r = vim.api.nvim_buf_get_text(current_buffer, s_start[2] - 1, s_start[3] - 1,
|
||||
s_end[2] - 1, s_end[3], {})
|
||||
-- print("region might be", current_buffer, s_start[2], s_start[3], s_end[2], s_end[3])
|
||||
return table.concat(r, "\n")
|
||||
end
|
||||
-- custom defined functions
|
||||
|
||||
-- Return the currently, visually selected text range
|
||||
function SL_get_visual_selection()
|
||||
vim.cmd([[ execute "normal! \<ESC>" ]])
|
||||
local s_start = vim.fn.getcharpos("'<")
|
||||
local s_end = vim.fn.getcharpos("'>")
|
||||
vim.cmd([[ execute "normal! gv" ]])
|
||||
|
||||
local current_buffer = vim.api.nvim_get_current_buf()
|
||||
local r = vim.api.nvim_buf_get_text(current_buffer, s_start[2] - 1, s_start[3] - 1,
|
||||
s_end[2] - 1, s_end[3], {})
|
||||
-- print("region might be", current_buffer, s_start[2], s_start[3], s_end[2], s_end[3])
|
||||
return table.concat(r, "\n")
|
||||
end
|
||||
|
||||
@@ -1,129 +1,129 @@
|
||||
-- Setup fzf-lua keybindings and some other searches
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" })
|
||||
vim.keymap.set('n', '<leader>fG', fzf.grep_cword, { desc = "Grep word under cursor" })
|
||||
vim.keymap.set('n', '<leader>fT', fzf.treesitter, { desc = "Treesitter symbols" })
|
||||
vim.keymap.set('n', '<leader>fc', fzf.commands, { desc = "Commands" })
|
||||
vim.keymap.set('n', '<leader>ff', fzf.files, { desc = "Find file" })
|
||||
vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" })
|
||||
vim.keymap.set('n', '<leader>fm', fzf.manpages, { desc = "Manpages" })
|
||||
vim.keymap.set('n', '<leader>fr', fzf.resume, { desc = "Resume last search" })
|
||||
vim.keymap.set('n', '<leader>fs', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', '<leader>f=', fzf.changes, { desc = "Changes" })
|
||||
vim.keymap.set('n', '<leader>fR', fzf.registers, { desc = "Registers" })
|
||||
vim.keymap.set('n', '<leader>fo', fzf.nvim_options, { desc = "NVim Options" })
|
||||
vim.keymap.set('n', '<leader>ft', ":TodoFzfLua<CR>", { desc = "Todos" })
|
||||
vim.keymap.set('n', '<leader>fl', fzf.git_bcommits, { desc = "Git buffer log" })
|
||||
|
||||
-- use fzf buffer lines as default search
|
||||
vim.keymap.set('n', '<C-/>', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" })
|
||||
|
||||
-- open file manager and git
|
||||
vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Neogit" })
|
||||
vim.keymap.set('n', '<leader>T', ":Neotree reveal<CR>", { desc = "Neotree Files" })
|
||||
vim.keymap.set('n', '<leader>F', ":Fyler kind=split_left<CR>", { desc = "Fyler Files" })
|
||||
|
||||
-- calendar
|
||||
vim.keymap.set('n', '<leader>c', ":Calendar -split=horizontal -position=below -height=12<CR>",
|
||||
{ desc = "Show calendar below" })
|
||||
vim.keymap.set('n', '<leader>C', ":Calendar -view=year -split=vertical -width=27<CR>", { desc = "Show calendar right" })
|
||||
|
||||
-- Open current file in browser (chromium)
|
||||
vim.keymap.set('n', '<space>o', ":silent !chromium '%'<cr>", { desc = "Open in browser" })
|
||||
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
-- Open org file folder in neotree
|
||||
vim.keymap.set('n', '<leader>of', ':silent :Neotree dir=/home/saschal/Documents/Eigene\\ (Briefe\\ etc.)/org<cr>',
|
||||
{ desc = "Open org folder" })
|
||||
end
|
||||
|
||||
-- toggle colorscheme between dark and light
|
||||
vim.keymap.set('n', '<leader>m', function()
|
||||
if vim.opt.background:get() == "dark" then
|
||||
vim.o.background = "light"
|
||||
else
|
||||
vim.o.background = "dark"
|
||||
end
|
||||
end, { desc = "Toggle dark/light mode" })
|
||||
|
||||
--
|
||||
-- configure workspaces
|
||||
-- also add a custom picker to fzf
|
||||
--
|
||||
local workspaces = require('workspaces')
|
||||
local workspaces_fzf_picker = function(opts)
|
||||
local fzf_lua = require('fzf-lua')
|
||||
opts = opts or {}
|
||||
opts.prompt = "Workspaces> "
|
||||
opts.actions = {
|
||||
['default'] = function(selected)
|
||||
workspaces.open(selected[1])
|
||||
end
|
||||
}
|
||||
fzf_lua.fzf_exec(function(fzf_cb)
|
||||
-- NOP
|
||||
local ws = workspaces.get()
|
||||
ws = ws or {}
|
||||
for i = 1, #ws do
|
||||
fzf_cb(ws[i].name)
|
||||
end
|
||||
fzf_cb() -- EOF
|
||||
end, opts)
|
||||
end
|
||||
vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Window layout save and restore
|
||||
--
|
||||
------------------------------------------
|
||||
|
||||
local layout = require('layout')
|
||||
vim.keymap.set('n', '<leader>ss', function()
|
||||
layout.save('default')
|
||||
print("Window layout saved")
|
||||
end, { desc = "Save window layout" })
|
||||
vim.keymap.set('n', '<leader>sr', function()
|
||||
layout.restore('default')
|
||||
print("Window layout restored")
|
||||
end, { desc = "Restore window layout" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Word higlighting
|
||||
--
|
||||
------------------------------------------
|
||||
local mywords = require('mywords')
|
||||
vim.keymap.set('n', '<space>mm', mywords.hl_toggle, { desc = "Highlight current word" })
|
||||
vim.keymap.set('n', '<space>mr', mywords.hl_toggle_regex, { desc = "Highlight regexp" })
|
||||
vim.keymap.set('n', '<space>mc', mywords.uhl_all, { desc = "Clear all highlights" })
|
||||
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Moving lines up and down
|
||||
--
|
||||
------------------------------------------
|
||||
|
||||
vim.keymap.set('n', '<M-Up>', ":m -2<cr>", { desc = "Move current line up" })
|
||||
vim.keymap.set('n', '<M-Down>', ":m +1<cr>", { desc = "Move current line down" })
|
||||
|
||||
vim.keymap.set('i', '<M-Up>', "<c-o>:m -2<cr>", { desc = "Move current line up" })
|
||||
vim.keymap.set('i', '<M-Down>', "<c-o>:m +1<cr>", { desc = "Move current line down" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Shortcuts which are known from Emacs
|
||||
--
|
||||
------------------------------------------
|
||||
vim.keymap.set('n', '<space>q', "gwap", { desc = "Wrap paragraph" })
|
||||
vim.keymap.set('n', '<esc><esc>', ":silent! nohls<CR>", { desc = "Clear search" })
|
||||
vim.keymap.set('i', '<c-Del>', '<c-o>dW', { desc = "Delete word right" })
|
||||
|
||||
-- horizontally scroll with mouse
|
||||
vim.keymap.set('n', '<S-ScrollWheelUp>', 'zh')
|
||||
vim.keymap.set('n', '<S-ScrollWheelDown>', 'zl')
|
||||
|
||||
vim.keymap.set('i', '<S-ScrollWheelUp>', '<c-o>zh')
|
||||
vim.keymap.set('i', '<S-ScrollWheelDown>', '<c-o>zl')
|
||||
-- Setup fzf-lua keybindings and some other searches
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" })
|
||||
vim.keymap.set('n', '<leader>fG', fzf.grep_cword, { desc = "Grep word under cursor" })
|
||||
vim.keymap.set('n', '<leader>fT', fzf.treesitter, { desc = "Treesitter symbols" })
|
||||
vim.keymap.set('n', '<leader>fc', fzf.commands, { desc = "Commands" })
|
||||
vim.keymap.set('n', '<leader>ff', fzf.files, { desc = "Find file" })
|
||||
vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" })
|
||||
vim.keymap.set('n', '<leader>fm', fzf.manpages, { desc = "Manpages" })
|
||||
vim.keymap.set('n', '<leader>fr', fzf.resume, { desc = "Resume last search" })
|
||||
vim.keymap.set('n', '<leader>fs', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', '<leader>f=', fzf.changes, { desc = "Changes" })
|
||||
vim.keymap.set('n', '<leader>fR', fzf.registers, { desc = "Registers" })
|
||||
vim.keymap.set('n', '<leader>fo', fzf.nvim_options, { desc = "NVim Options" })
|
||||
vim.keymap.set('n', '<leader>ft', ":TodoFzfLua<CR>", { desc = "Todos" })
|
||||
vim.keymap.set('n', '<leader>fl', fzf.git_bcommits, { desc = "Git buffer log" })
|
||||
|
||||
-- use fzf buffer lines as default search
|
||||
vim.keymap.set('n', '<C-/>', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" })
|
||||
|
||||
-- open file manager and git
|
||||
vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Neogit" })
|
||||
vim.keymap.set('n', '<leader>T', ":Neotree reveal<CR>", { desc = "Neotree Files" })
|
||||
vim.keymap.set('n', '<leader>F', ":Fyler kind=split_left<CR>", { desc = "Fyler Files" })
|
||||
|
||||
-- calendar
|
||||
vim.keymap.set('n', '<leader>c', ":Calendar -split=horizontal -position=below -height=12<CR>",
|
||||
{ desc = "Show calendar below" })
|
||||
vim.keymap.set('n', '<leader>C', ":Calendar -view=year -split=vertical -width=27<CR>", { desc = "Show calendar right" })
|
||||
|
||||
-- Open current file in browser (chromium)
|
||||
vim.keymap.set('n', '<space>o', ":silent !chromium '%'<cr>", { desc = "Open in browser" })
|
||||
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
-- Open org file folder in neotree
|
||||
vim.keymap.set('n', '<leader>of', ':silent :Neotree dir=/home/saschal/Documents/Eigene\\ (Briefe\\ etc.)/org<cr>',
|
||||
{ desc = "Open org folder" })
|
||||
end
|
||||
|
||||
-- toggle colorscheme between dark and light
|
||||
vim.keymap.set('n', '<leader>m', function()
|
||||
if vim.opt.background:get() == "dark" then
|
||||
vim.o.background = "light"
|
||||
else
|
||||
vim.o.background = "dark"
|
||||
end
|
||||
end, { desc = "Toggle dark/light mode" })
|
||||
|
||||
--
|
||||
-- configure workspaces
|
||||
-- also add a custom picker to fzf
|
||||
--
|
||||
local workspaces = require('workspaces')
|
||||
local workspaces_fzf_picker = function(opts)
|
||||
local fzf_lua = require('fzf-lua')
|
||||
opts = opts or {}
|
||||
opts.prompt = "Workspaces> "
|
||||
opts.actions = {
|
||||
['default'] = function(selected)
|
||||
workspaces.open(selected[1])
|
||||
end
|
||||
}
|
||||
fzf_lua.fzf_exec(function(fzf_cb)
|
||||
-- NOP
|
||||
local ws = workspaces.get()
|
||||
ws = ws or {}
|
||||
for i = 1, #ws do
|
||||
fzf_cb(ws[i].name)
|
||||
end
|
||||
fzf_cb() -- EOF
|
||||
end, opts)
|
||||
end
|
||||
vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Window layout save and restore
|
||||
--
|
||||
------------------------------------------
|
||||
|
||||
local layout = require('layout')
|
||||
vim.keymap.set('n', '<leader>ss', function()
|
||||
layout.save('default')
|
||||
print("Window layout saved")
|
||||
end, { desc = "Save window layout" })
|
||||
vim.keymap.set('n', '<leader>sr', function()
|
||||
layout.restore('default')
|
||||
print("Window layout restored")
|
||||
end, { desc = "Restore window layout" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Word higlighting
|
||||
--
|
||||
------------------------------------------
|
||||
local mywords = require('mywords')
|
||||
vim.keymap.set('n', '<space>mm', mywords.hl_toggle, { desc = "Highlight current word" })
|
||||
vim.keymap.set('n', '<space>mr', mywords.hl_toggle_regex, { desc = "Highlight regexp" })
|
||||
vim.keymap.set('n', '<space>mc', mywords.uhl_all, { desc = "Clear all highlights" })
|
||||
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Moving lines up and down
|
||||
--
|
||||
------------------------------------------
|
||||
|
||||
vim.keymap.set('n', '<M-Up>', ":m -2<cr>", { desc = "Move current line up" })
|
||||
vim.keymap.set('n', '<M-Down>', ":m +1<cr>", { desc = "Move current line down" })
|
||||
|
||||
vim.keymap.set('i', '<M-Up>', "<c-o>:m -2<cr>", { desc = "Move current line up" })
|
||||
vim.keymap.set('i', '<M-Down>', "<c-o>:m +1<cr>", { desc = "Move current line down" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
-- Shortcuts which are known from Emacs
|
||||
--
|
||||
------------------------------------------
|
||||
vim.keymap.set('n', '<space>q', "gwap", { desc = "Wrap paragraph" })
|
||||
vim.keymap.set('n', '<esc><esc>', ":silent! nohls<CR>", { desc = "Clear search" })
|
||||
vim.keymap.set('i', '<c-Del>', '<c-o>dW', { desc = "Delete word right" })
|
||||
|
||||
-- horizontally scroll with mouse
|
||||
vim.keymap.set('n', '<S-ScrollWheelUp>', 'zh')
|
||||
vim.keymap.set('n', '<S-ScrollWheelDown>', 'zl')
|
||||
|
||||
vim.keymap.set('i', '<S-ScrollWheelUp>', '<c-o>zh')
|
||||
vim.keymap.set('i', '<S-ScrollWheelDown>', '<c-o>zl')
|
||||
|
||||
142
lua/layout.lua
142
lua/layout.lua
@@ -1,71 +1,71 @@
|
||||
-- save and restore current window layout
|
||||
-- inspired by:
|
||||
-- - https://github.com/dedowsdi/.vim/blob/master/autoload/ddd/layout.vim
|
||||
-- - https://vi.stackexchange.com/a/22545/53081
|
||||
--
|
||||
-- added cursor position handling
|
||||
|
||||
local M = {}
|
||||
local layouts = {}
|
||||
local resize_cmds = {}
|
||||
|
||||
function M.save(name)
|
||||
layouts[name] = vim.fn.winlayout()
|
||||
resize_cmds[name] = vim.fn.winrestcmd()
|
||||
M.add_buf_to_layout(layouts[name])
|
||||
end
|
||||
|
||||
function M.add_buf_to_layout(layout)
|
||||
if layout[1] == "leaf" then
|
||||
local win_id = layout[2]
|
||||
table.insert(layout, vim.fn.winbufnr(win_id))
|
||||
table.insert(layout, vim.api.nvim_win_get_cursor(win_id))
|
||||
else
|
||||
for _, child_layout in ipairs(layout[2]) do
|
||||
M.add_buf_to_layout(child_layout)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.restore(name)
|
||||
if not layouts[name] then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create clean window
|
||||
vim.cmd("new")
|
||||
vim.cmd("wincmd o")
|
||||
|
||||
-- Recursively restore buffers and cursor positions
|
||||
M.apply_layout(layouts[name], name)
|
||||
|
||||
-- Resize
|
||||
vim.cmd(resize_cmds[name])
|
||||
end
|
||||
|
||||
function M.apply_layout(layout, name)
|
||||
if layout[1] == "leaf" then
|
||||
-- Load buffer for leaf
|
||||
if vim.fn.bufexists(layout[3]) == 1 then
|
||||
vim.cmd(string.format("b %d", layout[3]))
|
||||
-- Restore cursor position
|
||||
vim.api.nvim_win_set_cursor(vim.fn.win_getid(), layout[4])
|
||||
end
|
||||
else
|
||||
-- Split cols or rows, split n-1 times
|
||||
local split_method = layout[1] == "col" and "rightbelow split" or "rightbelow vsplit"
|
||||
local wins = { vim.fn.win_getid() }
|
||||
for i = 2, #layout[2] do
|
||||
vim.cmd(split_method)
|
||||
table.insert(wins, vim.fn.win_getid())
|
||||
end
|
||||
|
||||
-- Recursive into child windows
|
||||
for index, win_id in ipairs(wins) do
|
||||
vim.fn.win_gotoid(win_id)
|
||||
M.apply_layout(layout[2][index], name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
-- save and restore current window layout
|
||||
-- inspired by:
|
||||
-- - https://github.com/dedowsdi/.vim/blob/master/autoload/ddd/layout.vim
|
||||
-- - https://vi.stackexchange.com/a/22545/53081
|
||||
--
|
||||
-- added cursor position handling
|
||||
|
||||
local M = {}
|
||||
local layouts = {}
|
||||
local resize_cmds = {}
|
||||
|
||||
function M.save(name)
|
||||
layouts[name] = vim.fn.winlayout()
|
||||
resize_cmds[name] = vim.fn.winrestcmd()
|
||||
M.add_buf_to_layout(layouts[name])
|
||||
end
|
||||
|
||||
function M.add_buf_to_layout(layout)
|
||||
if layout[1] == "leaf" then
|
||||
local win_id = layout[2]
|
||||
table.insert(layout, vim.fn.winbufnr(win_id))
|
||||
table.insert(layout, vim.api.nvim_win_get_cursor(win_id))
|
||||
else
|
||||
for _, child_layout in ipairs(layout[2]) do
|
||||
M.add_buf_to_layout(child_layout)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.restore(name)
|
||||
if not layouts[name] then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create clean window
|
||||
vim.cmd("new")
|
||||
vim.cmd("wincmd o")
|
||||
|
||||
-- Recursively restore buffers and cursor positions
|
||||
M.apply_layout(layouts[name], name)
|
||||
|
||||
-- Resize
|
||||
vim.cmd(resize_cmds[name])
|
||||
end
|
||||
|
||||
function M.apply_layout(layout, name)
|
||||
if layout[1] == "leaf" then
|
||||
-- Load buffer for leaf
|
||||
if vim.fn.bufexists(layout[3]) == 1 then
|
||||
vim.cmd(string.format("b %d", layout[3]))
|
||||
-- Restore cursor position
|
||||
vim.api.nvim_win_set_cursor(vim.fn.win_getid(), layout[4])
|
||||
end
|
||||
else
|
||||
-- Split cols or rows, split n-1 times
|
||||
local split_method = layout[1] == "col" and "rightbelow split" or "rightbelow vsplit"
|
||||
local wins = { vim.fn.win_getid() }
|
||||
for i = 2, #layout[2] do
|
||||
vim.cmd(split_method)
|
||||
table.insert(wins, vim.fn.win_getid())
|
||||
end
|
||||
|
||||
-- Recursive into child windows
|
||||
for index, win_id in ipairs(wins) do
|
||||
vim.fn.win_gotoid(win_id)
|
||||
M.apply_layout(layout[2][index], name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
268
lua/lsp.lua
268
lua/lsp.lua
@@ -1,134 +1,134 @@
|
||||
-- attach using autocommand and setup keybindings
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('sl.lsp', {}),
|
||||
callback = function(args)
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = args.buf }
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "LSP show signature", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder,
|
||||
{ desc = "Workspace add folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder,
|
||||
{ desc = "Workspace remove folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, { desc = "Workspace list folders", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, { desc = "LSP Rename", unpack(bufopts) })
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, { desc = "LSP Format buffer", unpack(bufopts) })
|
||||
vim.keymap.set("n", '<space>F', ":silent !dx fmt --file %<cr>", { desc = "DX format rsx! regions", unpack(bufopts) })
|
||||
vim.keymap.set("v", "<space>f", LSPRangeFormatFunction, { desc = "LSP Format region" })
|
||||
|
||||
-- 2024-09-09 - some ccflow commands for diagnostics, symbols and code actions
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<space>d', fzf.diagnostics_document, { desc = "Document diagnostics" })
|
||||
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
|
||||
vim.keymap.set('n', '<space>e', function()
|
||||
local new_config = not vim.diagnostic.config().virtual_lines
|
||||
vim.diagnostic.config({ virtual_lines = new_config })
|
||||
end, { desc = "Virtual line diagnostics" })
|
||||
vim.keymap.set('n', '<space>E', vim.diagnostic.open_float, { desc = "Popup diagnostics" })
|
||||
vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" })
|
||||
vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" })
|
||||
vim.keymap.set('n', '<space>[', vim.diagnostic.goto_prev, { desc = "Previous diagnostics" })
|
||||
vim.keymap.set('n', '<space>]', vim.diagnostic.goto_next, { desc = "Previous diagnostics" })
|
||||
|
||||
local gitsigns = require('gitsigns')
|
||||
vim.keymap.set('n', '<space>=l', ":NeogitLogCurrent<CR>", { desc = "Neogit: log for this file" })
|
||||
vim.keymap.set('n', '<space>==', gitsigns.preview_hunk_inline, { desc = "Git hunk preview" })
|
||||
vim.keymap.set('n', '<space>=B', gitsigns.blame, { desc = "Git blame file" })
|
||||
vim.keymap.set('n', '<space>=D', function() gitsigns.diffthis('~') end, { desc = "Git diff this (~)" })
|
||||
vim.keymap.set('n', '<space>=R', gitsigns.reset_buffer, { desc = "Git reset file" })
|
||||
vim.keymap.set('n', '<space>=S', gitsigns.stage_buffer, { desc = "Git stage file" })
|
||||
vim.keymap.set('n', '<space>=[', gitsigns.prev_hunk, { desc = "Git previous hunk" })
|
||||
vim.keymap.set('n', '<space>=]', gitsigns.next_hunk, { desc = "Git next hunk" })
|
||||
vim.keymap.set('n', '<space>=b', gitsigns.blame_line, { desc = "Git blame line" })
|
||||
vim.keymap.set('n', '<space>=d', gitsigns.diffthis, { desc = "Git diff this" })
|
||||
vim.keymap.set('n', '<space>=r', gitsigns.reset_hunk, { desc = "Git reset hunk" })
|
||||
vim.keymap.set('n', '<space>=s', gitsigns.stage_hunk, { desc = "Git stage hunk" })
|
||||
vim.keymap.set('v', '<space>=s', function() gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end,
|
||||
{ desc = "Git stage hunk" })
|
||||
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<C-,>', fzf.lsp_references, { desc = "Find References" })
|
||||
vim.keymap.set('n', '<C-.>', fzf.lsp_definitions, { desc = "Find References" })
|
||||
end
|
||||
})
|
||||
|
||||
-- lsp format selected range
|
||||
function LSPRangeFormatFunction()
|
||||
vim.lsp.buf.format({
|
||||
async = true,
|
||||
range = {
|
||||
["start"] = vim.api.nvim_buf_get_mark(0, "<"),
|
||||
["end"] = vim.api.nvim_buf_get_mark(0, ">"),
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
local enable_this_lsp = {}
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
-- VUE and Typescript as of vue-language-server 3.0.x
|
||||
-- taken from:
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#vtsls
|
||||
local vue_language_server_path = '/home/saschal/.config/yarn/global/node_modules'
|
||||
local vue_plugin = {
|
||||
name = '@vue/typescript-plugin',
|
||||
location = vue_language_server_path,
|
||||
languages = { 'vue' },
|
||||
configNamespace = 'typescript',
|
||||
}
|
||||
local vtsls_config = {
|
||||
settings = {
|
||||
vtsls = {
|
||||
tsserver = {
|
||||
globalPlugins = {
|
||||
vue_plugin,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
||||
}
|
||||
vim.lsp.config('vtsls', vtsls_config)
|
||||
|
||||
-- enable this list of lsps
|
||||
enable_this_lsp = {
|
||||
'vue_ls',
|
||||
'vtsls',
|
||||
'gopls',
|
||||
'bashls',
|
||||
'html',
|
||||
'lua_ls',
|
||||
'jsonls', -- arch extra: vscode-json-languageserver
|
||||
'kotlin_lsp', -- arch aur: kotlin-lsp-bin
|
||||
'lemminx', -- arch aur: lemminx
|
||||
'clangd',
|
||||
'basedpyright',
|
||||
'wgsl_analyzer',
|
||||
}
|
||||
else
|
||||
-- any lsp which should be enabled in all situations
|
||||
enable_this_lsp = {
|
||||
}
|
||||
end
|
||||
|
||||
for l in pairs(enable_this_lsp) do
|
||||
vim.lsp.enable(enable_this_lsp[l])
|
||||
end
|
||||
|
||||
|
||||
-- add autoformat to Dioxus projects
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = "*.rs",
|
||||
callback = function()
|
||||
local cwd = vim.lsp.buf.list_workspace_folders()
|
||||
if not (cwd == nil) then
|
||||
if vim.fn.filereadable(cwd[1] .. "/Dioxus.toml") == 1 then
|
||||
local command = "dx fmt --file %"
|
||||
vim.cmd("silent ! " .. command)
|
||||
-- vim.notify(command)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- attach using autocommand and setup keybindings
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('sl.lsp', {}),
|
||||
callback = function(args)
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = args.buf }
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "LSP show signature", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder,
|
||||
{ desc = "Workspace add folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder,
|
||||
{ desc = "Workspace remove folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, { desc = "Workspace list folders", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, { desc = "LSP Rename", unpack(bufopts) })
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, { desc = "LSP Format buffer", unpack(bufopts) })
|
||||
vim.keymap.set("n", '<space>F', ":silent !dx fmt --file %<cr>", { desc = "DX format rsx! regions", unpack(bufopts) })
|
||||
vim.keymap.set("v", "<space>f", LSPRangeFormatFunction, { desc = "LSP Format region" })
|
||||
|
||||
-- 2024-09-09 - some ccflow commands for diagnostics, symbols and code actions
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<space>d', fzf.diagnostics_document, { desc = "Document diagnostics" })
|
||||
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
|
||||
vim.keymap.set('n', '<space>e', function()
|
||||
local new_config = not vim.diagnostic.config().virtual_lines
|
||||
vim.diagnostic.config({ virtual_lines = new_config })
|
||||
end, { desc = "Virtual line diagnostics" })
|
||||
vim.keymap.set('n', '<space>E', vim.diagnostic.open_float, { desc = "Popup diagnostics" })
|
||||
vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" })
|
||||
vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" })
|
||||
vim.keymap.set('n', '<space>[', vim.diagnostic.goto_prev, { desc = "Previous diagnostics" })
|
||||
vim.keymap.set('n', '<space>]', vim.diagnostic.goto_next, { desc = "Previous diagnostics" })
|
||||
|
||||
local gitsigns = require('gitsigns')
|
||||
vim.keymap.set('n', '<space>=l', ":NeogitLogCurrent<CR>", { desc = "Neogit: log for this file" })
|
||||
vim.keymap.set('n', '<space>==', gitsigns.preview_hunk_inline, { desc = "Git hunk preview" })
|
||||
vim.keymap.set('n', '<space>=B', gitsigns.blame, { desc = "Git blame file" })
|
||||
vim.keymap.set('n', '<space>=D', function() gitsigns.diffthis('~') end, { desc = "Git diff this (~)" })
|
||||
vim.keymap.set('n', '<space>=R', gitsigns.reset_buffer, { desc = "Git reset file" })
|
||||
vim.keymap.set('n', '<space>=S', gitsigns.stage_buffer, { desc = "Git stage file" })
|
||||
vim.keymap.set('n', '<space>=[', gitsigns.prev_hunk, { desc = "Git previous hunk" })
|
||||
vim.keymap.set('n', '<space>=]', gitsigns.next_hunk, { desc = "Git next hunk" })
|
||||
vim.keymap.set('n', '<space>=b', gitsigns.blame_line, { desc = "Git blame line" })
|
||||
vim.keymap.set('n', '<space>=d', gitsigns.diffthis, { desc = "Git diff this" })
|
||||
vim.keymap.set('n', '<space>=r', gitsigns.reset_hunk, { desc = "Git reset hunk" })
|
||||
vim.keymap.set('n', '<space>=s', gitsigns.stage_hunk, { desc = "Git stage hunk" })
|
||||
vim.keymap.set('v', '<space>=s', function() gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end,
|
||||
{ desc = "Git stage hunk" })
|
||||
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<C-,>', fzf.lsp_references, { desc = "Find References" })
|
||||
vim.keymap.set('n', '<C-.>', fzf.lsp_definitions, { desc = "Find References" })
|
||||
end
|
||||
})
|
||||
|
||||
-- lsp format selected range
|
||||
function LSPRangeFormatFunction()
|
||||
vim.lsp.buf.format({
|
||||
async = true,
|
||||
range = {
|
||||
["start"] = vim.api.nvim_buf_get_mark(0, "<"),
|
||||
["end"] = vim.api.nvim_buf_get_mark(0, ">"),
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
local enable_this_lsp = {}
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
-- VUE and Typescript as of vue-language-server 3.0.x
|
||||
-- taken from:
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#vtsls
|
||||
local vue_language_server_path = '/home/saschal/.config/yarn/global/node_modules'
|
||||
local vue_plugin = {
|
||||
name = '@vue/typescript-plugin',
|
||||
location = vue_language_server_path,
|
||||
languages = { 'vue' },
|
||||
configNamespace = 'typescript',
|
||||
}
|
||||
local vtsls_config = {
|
||||
settings = {
|
||||
vtsls = {
|
||||
tsserver = {
|
||||
globalPlugins = {
|
||||
vue_plugin,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
||||
}
|
||||
vim.lsp.config('vtsls', vtsls_config)
|
||||
|
||||
-- enable this list of lsps
|
||||
enable_this_lsp = {
|
||||
'vue_ls',
|
||||
'vtsls',
|
||||
'gopls',
|
||||
'bashls',
|
||||
'html',
|
||||
'lua_ls',
|
||||
'jsonls', -- arch extra: vscode-json-languageserver
|
||||
'kotlin_lsp', -- arch aur: kotlin-lsp-bin
|
||||
'lemminx', -- arch aur: lemminx
|
||||
'clangd',
|
||||
'basedpyright',
|
||||
'wgsl_analyzer',
|
||||
}
|
||||
else
|
||||
-- any lsp which should be enabled in all situations
|
||||
enable_this_lsp = {
|
||||
}
|
||||
end
|
||||
|
||||
for l in pairs(enable_this_lsp) do
|
||||
vim.lsp.enable(enable_this_lsp[l])
|
||||
end
|
||||
|
||||
|
||||
-- add autoformat to Dioxus projects
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = "*.rs",
|
||||
callback = function()
|
||||
local cwd = vim.lsp.buf.list_workspace_folders()
|
||||
if not (cwd == nil) then
|
||||
if vim.fn.filereadable(cwd[1] .. "/Dioxus.toml") == 1 then
|
||||
local command = "dx fmt --file %"
|
||||
vim.cmd("silent ! " .. command)
|
||||
-- vim.notify(command)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
166
lua/options.lua
166
lua/options.lua
@@ -1,70 +1,96 @@
|
||||
---------------------------------------------------
|
||||
--
|
||||
-- Some general setup taken from some tutorial
|
||||
-- which I have forgotten
|
||||
--
|
||||
--------------------------------------------------
|
||||
|
||||
-- Hint: use `:h <option>` to figure out the meaning if needed
|
||||
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||
|
||||
-- Tab
|
||||
vim.opt.tabstop = 2 -- number of visual spaces per TAB
|
||||
vim.opt.softtabstop = 2 -- number of spaces in tab when editing
|
||||
vim.opt.shiftwidth = 2 -- insert 4 spaces on a tab
|
||||
vim.opt.expandtab = true -- tabs are spaces, mainly because of python and because it is consistent
|
||||
|
||||
-- UI config
|
||||
vim.opt.number = true -- show absolute number
|
||||
vim.opt.relativenumber = false -- add numbers to each line on the left side
|
||||
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
||||
vim.opt.guicursor = "" .. -- cursor highlight group needs to be Cursor to have lunaperche have a proper light cursor
|
||||
"n-v-c-sm:block-Cursor,i-ci-ve:ver25-Cursor,r-cr-o:hor20,t:block-blinkon500-blinkoff500-Cursor"
|
||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||
vim.opt.splitright = true -- open new horizontal splits right
|
||||
vim.opt.termguicolors = true -- enable 24-bit RGB color in the TUI
|
||||
vim.opt.showmode = false -- we are experienced, wo don't need the "-- INSERT --" mode hint
|
||||
vim.opt.showtabline = 0 -- never show top line with tabs, not used anyways
|
||||
vim.opt.winborder = 'rounded' -- UI borders are rounded
|
||||
|
||||
-- Searching
|
||||
vim.opt.incsearch = true -- search as characters are entered
|
||||
vim.opt.hlsearch = true -- do not highlight matches
|
||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- General text editing and cursor movements
|
||||
--
|
||||
--------------------------------------------------
|
||||
|
||||
-- Wrapping movements and long lines
|
||||
vim.opt.whichwrap = "b,s,<,>,[,]" -- wrap backspace, space and left-right cursor keys
|
||||
vim.opt.wrap = false
|
||||
|
||||
-- Spelling
|
||||
vim.opt.spell = true
|
||||
vim.opt.spelllang = "de,en"
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- calendar.vim options
|
||||
--
|
||||
--------------------------------------------------
|
||||
-- :Calendar -split=horizontal -position=below -height=12
|
||||
|
||||
vim.g.calendar_first_day = "monday"
|
||||
vim.g.calendar_view = "year"
|
||||
vim.g.calendar_week_number = true
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- Other options
|
||||
--
|
||||
--------------------------------------------------
|
||||
|
||||
vim.opt.shortmess = vim.opt.shortmess + 'I'
|
||||
---------------------------------------------------
|
||||
--
|
||||
-- Global settings
|
||||
--
|
||||
---------------------------------------------------
|
||||
|
||||
-- global
|
||||
|
||||
sl_opt = {}
|
||||
|
||||
|
||||
-- this is specific for a machine
|
||||
if vim.loop.os_gethostname() == 'ccflow' then
|
||||
sl_opt = {
|
||||
org_agenda_files = '~/Documents/Eigene (Briefe etc.)/org/*.org',
|
||||
org_default_notes_file = '~/Documents/Eigene (Briefe etc.)/org/refile.org',
|
||||
org_roam_folder = '~/Documents/Eigene (Briefe etc.)/org/roam',
|
||||
}
|
||||
else
|
||||
sl_opt = {
|
||||
org_agenda_files = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles/*.org',
|
||||
org_default_notes_file = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles/refile.org',
|
||||
org_roam_folder = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles/roam',
|
||||
}
|
||||
end
|
||||
|
||||
---------------------------------------------------
|
||||
--
|
||||
-- Some general setup taken from some tutorial
|
||||
-- which I have forgotten
|
||||
--
|
||||
--------------------------------------------------
|
||||
|
||||
-- Hint: use `:h <option>` to figure out the meaning if needed
|
||||
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||
|
||||
-- Tab
|
||||
vim.opt.tabstop = 2 -- number of visual spaces per TAB
|
||||
vim.opt.softtabstop = 2 -- number of spaces in tab when editing
|
||||
vim.opt.shiftwidth = 2 -- insert 4 spaces on a tab
|
||||
vim.opt.expandtab = true -- tabs are spaces, mainly because of python and because it is consistent
|
||||
|
||||
-- UI config
|
||||
vim.opt.number = true -- show absolute number
|
||||
vim.opt.relativenumber = false -- add numbers to each line on the left side
|
||||
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
||||
vim.opt.guicursor = "" .. -- cursor highlight group needs to be Cursor to have lunaperche have a proper light cursor
|
||||
"n-v-c-sm:block-Cursor,i-ci-ve:ver25-Cursor,r-cr-o:hor20,t:block-blinkon500-blinkoff500-Cursor"
|
||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||
vim.opt.splitright = true -- open new horizontal splits right
|
||||
vim.opt.termguicolors = true -- enable 24-bit RGB color in the TUI
|
||||
vim.opt.showmode = false -- we are experienced, wo don't need the "-- INSERT --" mode hint
|
||||
vim.opt.showtabline = 0 -- never show top line with tabs, not used anyways
|
||||
vim.opt.winborder = 'rounded' -- UI borders are rounded
|
||||
|
||||
-- Searching
|
||||
vim.opt.incsearch = true -- search as characters are entered
|
||||
vim.opt.hlsearch = true -- do not highlight matches
|
||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- General text editing and cursor movements
|
||||
--
|
||||
--------------------------------------------------
|
||||
|
||||
-- Wrapping movements and long lines
|
||||
vim.opt.whichwrap = "b,s,<,>,[,]" -- wrap backspace, space and left-right cursor keys
|
||||
vim.opt.wrap = false
|
||||
|
||||
-- Spelling
|
||||
vim.opt.spell = true
|
||||
vim.opt.spelllang = "de,en"
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- calendar.vim options
|
||||
--
|
||||
--------------------------------------------------
|
||||
-- :Calendar -split=horizontal -position=below -height=12
|
||||
|
||||
vim.g.calendar_first_day = "monday"
|
||||
vim.g.calendar_view = "year"
|
||||
vim.g.calendar_week_number = true
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- Other options
|
||||
--
|
||||
--------------------------------------------------
|
||||
|
||||
vim.opt.shortmess = vim.opt.shortmess + 'I'
|
||||
|
||||
1125
lua/plugins.lua
1125
lua/plugins.lua
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user