Compare commits

..

3 Commits

25 changed files with 2146 additions and 2092 deletions

2
.gitignore vendored
View File

@@ -1 +1 @@
lazy-lock.json
lazy-lock.json

View File

@@ -1,3 +1,3 @@
{
"diagnostics.globals": ["vim"],
}
{
"diagnostics.globals": ["vim"],
}

View File

@@ -1,3 +1,3 @@
-- Options for AsciiDoc files, mainly used in diary situations
-- (pun intended)
vim.opt.textwidth = 80
-- Options for AsciiDoc files, mainly used in diary situations
-- (pun intended)
vim.opt.textwidth = 80

View File

@@ -1,13 +1,13 @@
-- make C-CR in insert mode behave like org_meta_return
-- in normal mode
vim.keymap.set(
"i",
"<C-CR>",
'<cmd>lua require("orgmode").action("org_mappings.meta_return")<CR>', {
silent = true,
buffer = true,
desc = 'ORG: meta return'
}
)
-- make C-CR in insert mode behave like org_meta_return
-- in normal mode
vim.keymap.set(
"i",
"<C-CR>",
'<cmd>lua require("orgmode").action("org_mappings.meta_return")<CR>', {
silent = true,
buffer = true,
desc = 'ORG: meta return'
}
)

View File

@@ -1,37 +1,37 @@
local bufnr = vim.api.nvim_get_current_buf()
vim.keymap.set(
"n",
"<space>x",
function()
vim.cmd.RustLsp({ 'explainError', 'current' })
end,
{ silent = true, buffer = bufnr, desc = 'RustLSP: explain error at cursor' }
)
-- show run targets
vim.keymap.set(
"n",
"<f5>",
function()
vim.cmd.RustLsp({ 'runnables' })
end,
{ silent = true, buffer = bufnr, desc = 'RustLSP: show runnables' }
)
-- run last target
vim.keymap.set(
"n",
"<S-f5>",
function()
vim.cmd.RustLsp({ 'runnables', bang = true })
end,
{ silent = true, buffer = bufnr, desc = 'RustLSP: show runnables' }
)
-- override signature hover to use RustLsp
vim.keymap.set('n', 'K', ":RustLsp hover actions<cr>", { desc = "RustLSP show signature" })
vim.keymap.set('n', 'J', ":RustLsp joinLines<cr>", { desc = "RustLSP join lines" })
local bufnr = vim.api.nvim_get_current_buf()
vim.keymap.set(
"n",
"<space>x",
function()
vim.cmd.RustLsp({ 'explainError', 'current' })
end,
{ silent = true, buffer = bufnr, desc = 'RustLSP: explain error at cursor' }
)
-- show run targets
vim.keymap.set(
"n",
"<f5>",
function()
vim.cmd.RustLsp({ 'runnables' })
end,
{ silent = true, buffer = bufnr, desc = 'RustLSP: show runnables' }
)
-- run last target
vim.keymap.set(
"n",
"<S-f5>",
function()
vim.cmd.RustLsp({ 'runnables', bang = true })
end,
{ silent = true, buffer = bufnr, desc = 'RustLSP: show runnables' }
)
-- override signature hover to use RustLsp
vim.keymap.set('n', 'K', ":RustLsp hover actions<cr>", { desc = "RustLSP show signature" })
vim.keymap.set('n', 'J', ":RustLsp joinLines<cr>", { desc = "RustLSP join lines" })

View File

@@ -1,4 +1,4 @@
runtime colors/lunaperche.vim
" fix VertSplit for lunaperche
hi VertSplit guifg=#aaaaaa
runtime colors/lunaperche.vim
" fix VertSplit for lunaperche
hi VertSplit guifg=#aaaaaa

View File

@@ -1,3 +1,10 @@
-- adjust proxy on Windows
if vim.loop.os_environ().OS == 'Windows_NT' then
-- TODO move out of the tree and do not check in
vim.fn.setenv("http_proxy", "http://10.167.16.21:80")
vim.fn.setenv("https_proxy", "http://10.167.16.21:80")
end
-- load configurations files from lua/*
require('filetype')
require('options')
@@ -6,5 +13,7 @@ require('plugins')
require('colorscheme')
require('lsp')
require('keybindings')
require('diary')
require('layout')
if vim.loop.os_gethostname() == 'ccflow' then
require('diary')
end

View File

@@ -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

View File

@@ -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)

View File

@@ -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 = {}
}

View File

@@ -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 = 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 = '?' })

View File

@@ -1,5 +1,5 @@
vim.filetype.add({
extension = {
CON = 'confile',
},
})
vim.filetype.add({
extension = {
CON = 'confile',
},
})

View File

@@ -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

View File

@@ -1,125 +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" })
-- 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" })
-- 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')

View File

@@ -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

View File

@@ -1,128 +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
-- 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
local 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',
}
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,
})

View File

@@ -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'

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +1,67 @@
-- these are already defined elsewhere, but LSP does not recognize that
-- doc says luasnip.config.snip_env
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
-- ensure current locale is used to format dates
local curlang = os.getenv("LANG")
os.setlocale(curlang)
return {
-- = Oktober 2024
-- :toc:
-- :numbered!:
--
-- <cursor>
s("diahead",
{
t "= ",
f(function() return os.date("%0B %Y") end),
t({ "", "", }),
t({ ":toc:", "" }),
t({ ":numbered!:", "" }),
t({ "", "", }),
}
),
-- == 7. Oktober, 11:14, Montag
--
-- <cursor>
s("diaentry",
{
t "== ",
f(function() return os.date("%e. %0B, %H:%M, %A") end),
t({ "", "", }),
t({ "", "", }),
}
),
}
--
-- these are already defined elsewhere, but LSP does not recognize that
-- doc says luasnip.config.snip_env
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
-- ensure current locale is used to format dates
local curlang = os.getenv("LANG")
os.setlocale(curlang)
return {
-- = Oktober 2024
-- :toc:
-- :numbered!:
--
-- <cursor>
s("diahead",
{
t "= ",
f(function() return os.date("%0B %Y") end),
t({ "", "", }),
t({ ":toc:", "" }),
t({ ":numbered!:", "" }),
t({ "", "", }),
}
),
-- == 7. Oktober, 11:14, Montag
--
-- <cursor>
s("diaentry",
{
t "== ",
f(function() return os.date("%e. %0B, %H:%M, %A") end),
t({ "", "", }),
t({ "", "", }),
}
),
}
--

View File

@@ -1,16 +1,16 @@
# ccflow local snippets for all modes
snippet todo "Add a TODO marker"
// TODO.`strftime("%Y-%m-%d -")`
snippet note "Add a NOTE marker"
// NOTE.`strftime("%Y-%m-%d -")`
snippet date "Insert current date"
`strftime("%Y-%m-%d ")`
snippet datetime "Insert current date and time"
`strftime("%Y-%m-%d %H:%M ")`
snippet lorem "Insert a lorem ipsum paragraph"
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
# ccflow local snippets for all modes
snippet todo "Add a TODO marker"
// TODO.`strftime("%Y-%m-%d -")`
snippet note "Add a NOTE marker"
// NOTE.`strftime("%Y-%m-%d -")`
snippet date "Insert current date"
`strftime("%Y-%m-%d ")`
snippet datetime "Insert current date and time"
`strftime("%Y-%m-%d %H:%M ")`
snippet lorem "Insert a lorem ipsum paragraph"
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@@ -1,280 +1,280 @@
snippet v "shorthand variable declaration"
${1} := ${2}
snippet vr "variable initialization"
var ${1:t} ${0:string}
snippet var "variable declaration"
var ${1} ${2} = ${3}
snippet vars "variables declaration"
var (
${1} ${2} = ${3}
)
snippet ap "append"
append(${1:slice}, ${0:value})
snippet bl "bool"
bool
snippet bt "byte"
byte
snippet br "break"
break
snippet ch "channel"
chan ${0:int}
snippet cs "case"
case ${1:value}:
${0:${VISUAL}}
snippet co "constants with iota"
const (
${1:NAME1} = iota
${0:NAME2}
)
snippet cn "continue"
continue
snippet df "defer"
defer ${0:func}()
snippet dfr "defer recover"
defer func() {
if err := recover(); err != nil {
${0:${VISUAL}}
}
}()
snippet im "import"
import (
"${1:package}"
)
snippet in "interface"
interface{}
snippet inf "full interface "
type ${1:name} interface {
${2:/* methods */}
}
snippet if "if condition"
if $1 {
${2:${VISUAL}}
}
snippet ife "if else condition"
if $1 {
${2:${VISUAL}}
} else {
${0}
}
snippet el "else"
else {
${0:${VISUAL}}
}
snippet ir "if error not nil, return err"
if err != nil {
return err
}
${0}
snippet f "false"
false
snippet ft "fallthrough"
fallthrough
snippet fl "float"
float32
snippet f3 "float32"
float32
snippet f6 "float64"
float64
snippet for "for loop"
for ${1}{
${0:${VISUAL}}
}
snippet fori "for int loop"
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
${0:${VISUAL}}
}
snippet forr "for range loop"
for ${1:e} := range ${2:collection} {
${0:${VISUAL}}
}
snippet fun "function"
func ${1:funcName}(${2}) ${3:error} {
${4}
}
${0}
snippet fum "method"
func (${1:receiver} ${2:type}) ${3:funcName}(${4}) ${5:error} {
${6}
}
${0}
snippet fumh "http handler function on receiver"
func (${1:receiver} ${2:type}) ${3:funcName}(${4:w} http.ResponseWriter, ${5:r} *http.Request) {
${0:${VISUAL}}
}
snippet lf "log printf"
log.Printf("%${1:s}", ${2:var})
snippet lp "log println"
log.Println("${1}")
snippet mk "make"
make(${1:[]string}, ${0:0})
snippet mp "map"
map[${1:string}]${0:int}
snippet main "func main()"
func main() {
${1}
}
${0}
snippet nw "new"
new(${0:type})
snippet pa "package"
package ${1:main}
snippet pn "panic"
panic("${0:msg}")
snippet pf "fmt.Printf()"
fmt.Printf("%${1:s}\n", ${2:var})
snippet pl "fmt.Println()"
fmt.Println("${1:s}")
snippet rn "range"
range ${0}
snippet rt "return"
return ${0}
snippet rs "result"
result
snippet sl "select"
select {
case ${1:v1} := <-${2:chan1}
${3}
default:
${0}
}
snippet sr "string"
string
snippet st "struct"
type ${1:name} struct {
${2:/* data */}
}
${0}
snippet sw "switch"
switch ${1:var} {
case ${2:value1}:
${3}
case ${4:value2}:
${5}
default:
${0}
}
snippet ps "fmt.Sprintf"
fmt.Sprintf("%${1:s}", ${2:var})
snippet t "true"
true
snippet g "goroutine named function"
go ${1:funcName}(${0})
snippet ga "goroutine anonymous function"
go func(${1} ${2:type}) {
${3:/* code */}
}(${0})
snippet test "test function"
func Test${1:name}(t *testing.T) {
${0:${VISUAL}}
}
snippet testt "table test function"
func Test${1:name}(t *testing.T) {
tests := []struct {
name string
}{
{
name: "${2:test name}",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
${0:${VISUAL}}
})
}
}
snippet bench "benchmark function"
func Benchmark${1:name}(b *testing.B) {
for i := 0; i < b.N; i++ {
${2}
}
}
${0}
snippet cl "composite literals"
type ${1:name} struct {
${2:attrName} ${3:attrType}
}
snippet om "if key in a map"
if ${1:value}, ok := ${2:map}[${3:key}]; ok == true {
${4:/* code */}
}
snippet gg "Grouped globals with anonymous struct"
var ${1:var} = struct{
${2:name} ${3:type}
}{
$2: ${4:value},
}
snippet ja "Marshalable json alias"
type ${1:parentType}Alias $1
func (p *$1) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct{ *$1Alias }{(*$1Alias)(p)})
}
snippet errwr "Error handling with fmt.Errorf"
if ${1}err != nil {
return fmt.Errorf("${2} %w", err)
}
snippet v "shorthand variable declaration"
${1} := ${2}
snippet vr "variable initialization"
var ${1:t} ${0:string}
snippet var "variable declaration"
var ${1} ${2} = ${3}
snippet vars "variables declaration"
var (
${1} ${2} = ${3}
)
snippet ap "append"
append(${1:slice}, ${0:value})
snippet bl "bool"
bool
snippet bt "byte"
byte
snippet br "break"
break
snippet ch "channel"
chan ${0:int}
snippet cs "case"
case ${1:value}:
${0:${VISUAL}}
snippet co "constants with iota"
const (
${1:NAME1} = iota
${0:NAME2}
)
snippet cn "continue"
continue
snippet df "defer"
defer ${0:func}()
snippet dfr "defer recover"
defer func() {
if err := recover(); err != nil {
${0:${VISUAL}}
}
}()
snippet im "import"
import (
"${1:package}"
)
snippet in "interface"
interface{}
snippet inf "full interface "
type ${1:name} interface {
${2:/* methods */}
}
snippet if "if condition"
if $1 {
${2:${VISUAL}}
}
snippet ife "if else condition"
if $1 {
${2:${VISUAL}}
} else {
${0}
}
snippet el "else"
else {
${0:${VISUAL}}
}
snippet ir "if error not nil, return err"
if err != nil {
return err
}
${0}
snippet f "false"
false
snippet ft "fallthrough"
fallthrough
snippet fl "float"
float32
snippet f3 "float32"
float32
snippet f6 "float64"
float64
snippet for "for loop"
for ${1}{
${0:${VISUAL}}
}
snippet fori "for int loop"
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
${0:${VISUAL}}
}
snippet forr "for range loop"
for ${1:e} := range ${2:collection} {
${0:${VISUAL}}
}
snippet fun "function"
func ${1:funcName}(${2}) ${3:error} {
${4}
}
${0}
snippet fum "method"
func (${1:receiver} ${2:type}) ${3:funcName}(${4}) ${5:error} {
${6}
}
${0}
snippet fumh "http handler function on receiver"
func (${1:receiver} ${2:type}) ${3:funcName}(${4:w} http.ResponseWriter, ${5:r} *http.Request) {
${0:${VISUAL}}
}
snippet lf "log printf"
log.Printf("%${1:s}", ${2:var})
snippet lp "log println"
log.Println("${1}")
snippet mk "make"
make(${1:[]string}, ${0:0})
snippet mp "map"
map[${1:string}]${0:int}
snippet main "func main()"
func main() {
${1}
}
${0}
snippet nw "new"
new(${0:type})
snippet pa "package"
package ${1:main}
snippet pn "panic"
panic("${0:msg}")
snippet pf "fmt.Printf()"
fmt.Printf("%${1:s}\n", ${2:var})
snippet pl "fmt.Println()"
fmt.Println("${1:s}")
snippet rn "range"
range ${0}
snippet rt "return"
return ${0}
snippet rs "result"
result
snippet sl "select"
select {
case ${1:v1} := <-${2:chan1}
${3}
default:
${0}
}
snippet sr "string"
string
snippet st "struct"
type ${1:name} struct {
${2:/* data */}
}
${0}
snippet sw "switch"
switch ${1:var} {
case ${2:value1}:
${3}
case ${4:value2}:
${5}
default:
${0}
}
snippet ps "fmt.Sprintf"
fmt.Sprintf("%${1:s}", ${2:var})
snippet t "true"
true
snippet g "goroutine named function"
go ${1:funcName}(${0})
snippet ga "goroutine anonymous function"
go func(${1} ${2:type}) {
${3:/* code */}
}(${0})
snippet test "test function"
func Test${1:name}(t *testing.T) {
${0:${VISUAL}}
}
snippet testt "table test function"
func Test${1:name}(t *testing.T) {
tests := []struct {
name string
}{
{
name: "${2:test name}",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
${0:${VISUAL}}
})
}
}
snippet bench "benchmark function"
func Benchmark${1:name}(b *testing.B) {
for i := 0; i < b.N; i++ {
${2}
}
}
${0}
snippet cl "composite literals"
type ${1:name} struct {
${2:attrName} ${3:attrType}
}
snippet om "if key in a map"
if ${1:value}, ok := ${2:map}[${3:key}]; ok == true {
${4:/* code */}
}
snippet gg "Grouped globals with anonymous struct"
var ${1:var} = struct{
${2:name} ${3:type}
}{
$2: ${4:value},
}
snippet ja "Marshalable json alias"
type ${1:parentType}Alias $1
func (p *$1) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct{ *$1Alias }{(*$1Alias)(p)})
}
snippet errwr "Error handling with fmt.Errorf"
if ${1}err != nil {
return fmt.Errorf("${2} %w", err)
}

View File

@@ -1,135 +1,135 @@
# Org Mode Snippets Imported from (https://github.com/doomemacs/snippets/)
# Imported by ybenel (github.com/m1ndo)
# Begin
snippet begin
#+begin_${1:type} ${2:options}
$0
#+end_$1
# Begin Center
snippet <C
#+begin_center
$0
#+end_center
# Begin Comment
snippet <c
#+begin_comment
$0
#+end_comment
# Begin Example
snippet <e
#+begin_example
$0
#+end_example
# Begin Export Ascii
snippet <a
#+begin_export ascii
$0
#+end_export
# Begin export html
snippet <h
#+begin_export html
$0
#+end_export
# Begin export Latex
snippet <l
#+begin_export latex
$0
#+end_export
# Begin export python
snippet <p
#+begin_export python
$0
#+end_export
# Begin export shell
snippet <s
#+begin_export shell
$0
#+end_export
# dot
snippet dot
#+begin_src dot :file ${1:file}.${2:svg} :results file graphics
$0
#+end_src
# elisp
snippet elisp
#+begin_src emacs-lisp :tangle yes
$0
#+end_src
# Entry
snippet entry
#+begin_html
---
layout: ${1:default}
title: ${2:title}
---
#+end_html
$0
# Begin example
snippet ex
#+begin_example
$0
#+end_example
# Begin export
snippet export
#+begin_export ${1:type}
$0
#+end_export
# Figure
snippet fig
#+caption: ${1:caption}
#+attr_latex: ${2:scale=0.75}
#+name: fig-${3:label}
# Org Header
snippet head
#+title: ${1:untitled document}
#+author: ${2:user-full-name}
#+email: ${3:user-mail-address}
# Image
snippet img
#+attr_html: :alt $2 :align ${3:left} :class img
[[${1:src}]${4:[${5:title}]}]
$0
# Inline
snippet inl
src_${1:language}${2:[${3::exports code}]}{${4:code}}
# Inline source
snippet srci
src_${1:language}[${2:header}]{${0:body}}
# Jupyter
snippet jupyter
#+begin_src jupyter-${1:$$(yas-choose-value '("python" "julia" "R"))}${2: :session $3}${4: :async yes}
$0
#+end_src
# Matrix (latex)
snippet matrix
\left \(
\begin{array}{${1:ccc}}
${2:v1 & v2} \\
$0
\end{array}
\right \)
# Name
snippet name
#+name: $0
# Quote
snippet quote
#+begin_quote
$0
#+end_quote
# Source
snippet src
#+begin_src $1
$0
#+end_src
# Todo
snippet todo
TODO ${1:task description}
# Verse
snippet verse
#+begin_verse
$0
#+end_verse
# Atrribute Width
snippet #+attr_html:width
#+attr_html: :width ${1:500px}
# Org Mode Snippets Imported from (https://github.com/doomemacs/snippets/)
# Imported by ybenel (github.com/m1ndo)
# Begin
snippet begin
#+begin_${1:type} ${2:options}
$0
#+end_$1
# Begin Center
snippet <C
#+begin_center
$0
#+end_center
# Begin Comment
snippet <c
#+begin_comment
$0
#+end_comment
# Begin Example
snippet <e
#+begin_example
$0
#+end_example
# Begin Export Ascii
snippet <a
#+begin_export ascii
$0
#+end_export
# Begin export html
snippet <h
#+begin_export html
$0
#+end_export
# Begin export Latex
snippet <l
#+begin_export latex
$0
#+end_export
# Begin export python
snippet <p
#+begin_export python
$0
#+end_export
# Begin export shell
snippet <s
#+begin_export shell
$0
#+end_export
# dot
snippet dot
#+begin_src dot :file ${1:file}.${2:svg} :results file graphics
$0
#+end_src
# elisp
snippet elisp
#+begin_src emacs-lisp :tangle yes
$0
#+end_src
# Entry
snippet entry
#+begin_html
---
layout: ${1:default}
title: ${2:title}
---
#+end_html
$0
# Begin example
snippet ex
#+begin_example
$0
#+end_example
# Begin export
snippet export
#+begin_export ${1:type}
$0
#+end_export
# Figure
snippet fig
#+caption: ${1:caption}
#+attr_latex: ${2:scale=0.75}
#+name: fig-${3:label}
# Org Header
snippet head
#+title: ${1:untitled document}
#+author: ${2:user-full-name}
#+email: ${3:user-mail-address}
# Image
snippet img
#+attr_html: :alt $2 :align ${3:left} :class img
[[${1:src}]${4:[${5:title}]}]
$0
# Inline
snippet inl
src_${1:language}${2:[${3::exports code}]}{${4:code}}
# Inline source
snippet srci
src_${1:language}[${2:header}]{${0:body}}
# Jupyter
snippet jupyter
#+begin_src jupyter-${1:$$(yas-choose-value '("python" "julia" "R"))}${2: :session $3}${4: :async yes}
$0
#+end_src
# Matrix (latex)
snippet matrix
\left \(
\begin{array}{${1:ccc}}
${2:v1 & v2} \\
$0
\end{array}
\right \)
# Name
snippet name
#+name: $0
# Quote
snippet quote
#+begin_quote
$0
#+end_quote
# Source
snippet src
#+begin_src $1
$0
#+end_src
# Todo
snippet todo
TODO ${1:task description}
# Verse
snippet verse
#+begin_verse
$0
#+end_verse
# Atrribute Width
snippet #+attr_html:width
#+attr_html: :width ${1:500px}

View File

@@ -1,252 +1,252 @@
#################
# Rust Snippets #
#################
# Functions
snippet fn "Function definition"
fn ${1:function_name}(${2})${3} {
${0}
}
snippet pfn "Function definition"
pub fn ${1:function_name}(${2})${3} {
${0}
}
snippet afn "Async function definition"
async fn ${1:function_name}(${2})${3} {
${0}
}
snippet pafn "Async function definition"
pub async fn ${1:function_name}(${2})${3} {
${0}
}
snippet bench "Bench function" b
#[bench]
fn ${1:bench_function_name}(b: &mut test::Bencher) {
b.iter(|| {
${0}
})
}
snippet new "Constructor function"
pub fn new(${2}) -> ${1:Self} {
$1 { ${3} }
}
snippet main "Main function"
pub fn main() {
${0}
}
snippet let "let variable declaration with type inference"
let ${1} = ${2};
snippet lett "let variable declaration with explicit type annotation"
let ${1}: ${2} = ${3};
snippet letm "let mut variable declaration with type inference"
let mut ${1} = ${2};
snippet lettm "let mut variable declaration with explicit type annotation"
let mut ${1}: ${2} = ${3};
snippet pri "print!"
print!("${1}");
snippet pri, "print! with format param"
print!("${1}{${2}}", ${3});
snippet pln "println!"
println!("${1}");
snippet pln, "println! with format param"
println!("${1}{${2}}", ${3});
snippet fmt "format!"
format!("${1}{${2}}", ${3});
snippet d "dbg! debugging macro"
dbg!(${0:${VISUAL}})
snippet d; "dbg! debugging macro statement"
dbg!(&${1});
${0}
# Modules
snippet ec "extern crate"
extern crate ${1:sync};
snippet ecl "extern crate log"
#[macro_use]
extern crate log;
snippet mod
mod ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
} /* $1 */
# Testing
snippet as "assert!"
assert!(${1:predicate});
snippet ase "assert_eq!"
assert_eq!(${1:expected}, ${2:actual});
snippet test "Unit test function"
#[test]
fn ${1:function_name}_test() {
${0}
}
snippet testmod "Test module" b
#[cfg(test)]
mod tests {
use super::${1:*};
test${0}
}
snippet ig "#[ignore]"
#[ignore]
# Attributes
snippet allow "allow lint attribute" b
#[allow(${1:unused_variables})]
snippet cfg "cfg attribute" b
#[cfg(${1:target_os = "linux"})]
snippet feat "feature attribute" b
#![feature(${1:plugin})]
snippet der "#[derive(..)]" b
#[derive(${1:Debug})]
snippet attr "#[..]" b
#[${1:inline}]
snippet crate "Define create meta attributes"
// Crate name
#![crate_name = "${1:crate_name}"]
// Additional metadata attributes
#![desc = "${2:Description.}"]
#![license = "${3:BSD}"]
#![comment = "${4:Comment.}"]
// Specify the output type
#![crate_type = "${5:lib}"]
# Common types
snippet opt "Option<T>"
Option<${1:i32}>
snippet res "Result<T, E>"
Result<${1:&str}, ${2:()}>
# Control structures
snippet if
if ${1} {
${0:${VISUAL}}
}
snippet ife "if / else"
if ${1} {
${2:${VISUAL}}
} else {
${0}
}
snippet ifl "if let (...)"
if let ${1:Some($2)} = $3 {
${0:${VISUAL}}
}
snippet el "else"
else {
${0:${VISUAL}}
}
snippet eli "else if"
else if ${1} {
${0:${VISUAL}}
}
snippet mat "match pattern"
match ${1} {
${2} => ${3}
}
snippet case "Case clause of pattern match"
${1:_} => ${2:expression}
snippet = "=> "
=> $0
snippet loop "loop {}" b
loop {
${0:${VISUAL}}
}
snippet wh "while loop"
while $1 {
${0:${VISUAL}}
}
snippet whl "while let (...)"
while let ${1:Some($2)} = $3 {
${0:${VISUAL}}
}
snippet for "for ... in ... loop"
for ${1:i} in ${2} {
${0}
}
# TODO commenting
snippet todo "TODO comment"
// TODO: $0
snippet fixme "FIXME comment"
// FIXME: $0
# Struct
snippet st "Struct definition"
struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
snippet impl "Struct/Trait implementation"
impl ${1:Type/Trait}${2: for $3} {
${0}
}
snippet stn "Struct with new constructor"
pub struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
impl$2 $1$2 {
pub fn new(${4}) -> Self {
$1 { ${5} }
}
}
snippet ty "Type alias"
type ${1:NewName} = $2;
snippet enum "enum definition"
enum ${1:Name} {
${2},
}
snippet penum "pub enum definition"
pub enum ${1:Name} {
${2},
}
# Traits
snippet trait "Trait definition"
trait ${1:Name} {
${0}
}
snippet drop "Drop trait implementation (destructor)"
impl Drop for $1 {
fn drop(&mut self) {
${0}
}
}
# Statics
snippet ss "static string declaration"
static ${1}: &'static str = "${0}";
snippet stat "static item declaration"
static ${1}: ${2:usize} = ${0};
# Concurrency
snippet spawn "spawn a thread"
thread::spawn(${1:move }|| {
${0}
});
snippet chan "Declare (Sender, Receiver) pair of asynchronous channel()"
let (${1:tx}, ${2:rx}): (Sender<${3:i32}>, Receiver<${4:i32}>) = channel();
# Implementations
snippet asref "AsRef trait implementation"
impl AsRef<${1:Ref}> for ${2:Type} {
fn as_ref(&self) -> &${3:$1} {
&self.${0:field}
}
}
snippet asmut "AsMut trait implementation"
impl AsMut<${1:Ref}> for ${2:Type} {
fn as_mut(&mut self) -> &mut ${3:$1} {
&mut self.${0:field}
}
}
snippet fd "Struct field definition" w
${1:name}: ${2:Type},
snippet || "Closure, anonymous function (inline)" i
${1:move }|$2| { $3 }
snippet |} "Closure, anonymous function (block)" i
${1:move }|$2| {
$3
}
snippet macro "macro_rules!" b
macro_rules! ${1:name} {
(${2:matcher}) => (
$3
)
}
snippet boxp "Box::new()"
Box::new(${0:${VISUAL}})
snippet rc "Rc::new()"
Rc::new(${0:${VISUAL}})
snippet unim "unimplemented!()"
unimplemented!()
snippet use "use ...;" b
use ${1:std::$2};
#################
# Rust Snippets #
#################
# Functions
snippet fn "Function definition"
fn ${1:function_name}(${2})${3} {
${0}
}
snippet pfn "Function definition"
pub fn ${1:function_name}(${2})${3} {
${0}
}
snippet afn "Async function definition"
async fn ${1:function_name}(${2})${3} {
${0}
}
snippet pafn "Async function definition"
pub async fn ${1:function_name}(${2})${3} {
${0}
}
snippet bench "Bench function" b
#[bench]
fn ${1:bench_function_name}(b: &mut test::Bencher) {
b.iter(|| {
${0}
})
}
snippet new "Constructor function"
pub fn new(${2}) -> ${1:Self} {
$1 { ${3} }
}
snippet main "Main function"
pub fn main() {
${0}
}
snippet let "let variable declaration with type inference"
let ${1} = ${2};
snippet lett "let variable declaration with explicit type annotation"
let ${1}: ${2} = ${3};
snippet letm "let mut variable declaration with type inference"
let mut ${1} = ${2};
snippet lettm "let mut variable declaration with explicit type annotation"
let mut ${1}: ${2} = ${3};
snippet pri "print!"
print!("${1}");
snippet pri, "print! with format param"
print!("${1}{${2}}", ${3});
snippet pln "println!"
println!("${1}");
snippet pln, "println! with format param"
println!("${1}{${2}}", ${3});
snippet fmt "format!"
format!("${1}{${2}}", ${3});
snippet d "dbg! debugging macro"
dbg!(${0:${VISUAL}})
snippet d; "dbg! debugging macro statement"
dbg!(&${1});
${0}
# Modules
snippet ec "extern crate"
extern crate ${1:sync};
snippet ecl "extern crate log"
#[macro_use]
extern crate log;
snippet mod
mod ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
} /* $1 */
# Testing
snippet as "assert!"
assert!(${1:predicate});
snippet ase "assert_eq!"
assert_eq!(${1:expected}, ${2:actual});
snippet test "Unit test function"
#[test]
fn ${1:function_name}_test() {
${0}
}
snippet testmod "Test module" b
#[cfg(test)]
mod tests {
use super::${1:*};
test${0}
}
snippet ig "#[ignore]"
#[ignore]
# Attributes
snippet allow "allow lint attribute" b
#[allow(${1:unused_variables})]
snippet cfg "cfg attribute" b
#[cfg(${1:target_os = "linux"})]
snippet feat "feature attribute" b
#![feature(${1:plugin})]
snippet der "#[derive(..)]" b
#[derive(${1:Debug})]
snippet attr "#[..]" b
#[${1:inline}]
snippet crate "Define create meta attributes"
// Crate name
#![crate_name = "${1:crate_name}"]
// Additional metadata attributes
#![desc = "${2:Description.}"]
#![license = "${3:BSD}"]
#![comment = "${4:Comment.}"]
// Specify the output type
#![crate_type = "${5:lib}"]
# Common types
snippet opt "Option<T>"
Option<${1:i32}>
snippet res "Result<T, E>"
Result<${1:&str}, ${2:()}>
# Control structures
snippet if
if ${1} {
${0:${VISUAL}}
}
snippet ife "if / else"
if ${1} {
${2:${VISUAL}}
} else {
${0}
}
snippet ifl "if let (...)"
if let ${1:Some($2)} = $3 {
${0:${VISUAL}}
}
snippet el "else"
else {
${0:${VISUAL}}
}
snippet eli "else if"
else if ${1} {
${0:${VISUAL}}
}
snippet mat "match pattern"
match ${1} {
${2} => ${3}
}
snippet case "Case clause of pattern match"
${1:_} => ${2:expression}
snippet = "=> "
=> $0
snippet loop "loop {}" b
loop {
${0:${VISUAL}}
}
snippet wh "while loop"
while $1 {
${0:${VISUAL}}
}
snippet whl "while let (...)"
while let ${1:Some($2)} = $3 {
${0:${VISUAL}}
}
snippet for "for ... in ... loop"
for ${1:i} in ${2} {
${0}
}
# TODO commenting
snippet todo "TODO comment"
// TODO: $0
snippet fixme "FIXME comment"
// FIXME: $0
# Struct
snippet st "Struct definition"
struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
snippet impl "Struct/Trait implementation"
impl ${1:Type/Trait}${2: for $3} {
${0}
}
snippet stn "Struct with new constructor"
pub struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
impl$2 $1$2 {
pub fn new(${4}) -> Self {
$1 { ${5} }
}
}
snippet ty "Type alias"
type ${1:NewName} = $2;
snippet enum "enum definition"
enum ${1:Name} {
${2},
}
snippet penum "pub enum definition"
pub enum ${1:Name} {
${2},
}
# Traits
snippet trait "Trait definition"
trait ${1:Name} {
${0}
}
snippet drop "Drop trait implementation (destructor)"
impl Drop for $1 {
fn drop(&mut self) {
${0}
}
}
# Statics
snippet ss "static string declaration"
static ${1}: &'static str = "${0}";
snippet stat "static item declaration"
static ${1}: ${2:usize} = ${0};
# Concurrency
snippet spawn "spawn a thread"
thread::spawn(${1:move }|| {
${0}
});
snippet chan "Declare (Sender, Receiver) pair of asynchronous channel()"
let (${1:tx}, ${2:rx}): (Sender<${3:i32}>, Receiver<${4:i32}>) = channel();
# Implementations
snippet asref "AsRef trait implementation"
impl AsRef<${1:Ref}> for ${2:Type} {
fn as_ref(&self) -> &${3:$1} {
&self.${0:field}
}
}
snippet asmut "AsMut trait implementation"
impl AsMut<${1:Ref}> for ${2:Type} {
fn as_mut(&mut self) -> &mut ${3:$1} {
&mut self.${0:field}
}
}
snippet fd "Struct field definition" w
${1:name}: ${2:Type},
snippet || "Closure, anonymous function (inline)" i
${1:move }|$2| { $3 }
snippet |} "Closure, anonymous function (block)" i
${1:move }|$2| {
$3
}
snippet macro "macro_rules!" b
macro_rules! ${1:name} {
(${2:matcher}) => (
$3
)
}
snippet boxp "Box::new()"
Box::new(${0:${VISUAL}})
snippet rc "Rc::new()"
Rc::new(${0:${VISUAL}})
snippet unim "unimplemented!()"
unimplemented!()
snippet use "use ...;" b
use ${1:std::$2};

View File

@@ -1,97 +1,97 @@
snippet apply-templates with-param
<xsl:apply-templates select="${1:*}">
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
</xsl:apply-templates>
snippet apply-templates sort-by
<xsl:apply-templates select="${1:*}">
<xsl:sort select="${2:node}" order="${3:ascending}" data-type="${4:text}">${5}
</xsl:apply-templates>
snippet apply-templates plain
<xsl:apply-templates select="${1:*}" />
snippet attribute blank
<xsl:attribute name="${1:name}">${2}</xsl:attribute>
snippet attribute value-of
<xsl:attribute name="${1:name}">
<xsl:value-of select="${2:*}" />
</xsl:attribute>
snippet call-template
<xsl:call-template name="${1:template}" />
snippet call-template with-param
<xsl:call-template name="${1:template}">
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
</xsl:call-template>
snippet choose
<xsl:choose>
<xsl:when test="${1:value}">
${2}
</xsl:when>
</xsl:choose>
snippet copy-of
<xsl:copy-of select="${1:*}" />
snippet for-each
<xsl:for-each select="${1:*}">${2}
</xsl:for-each>
snippet if
<xsl:if test="${1:test}">${2}
</xsl:if>
snippet import
<xsl:import href="${1:stylesheet}" />
snippet include
<xsl:include href="${1:stylesheet}" />
snippet otherwise
<xsl:otherwise>${0}
</xsl:otherwise>
snippet param
<xsl:param name="${1:name}">${2}
</xsl:param>
snippet stylesheet
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">${0}
</xsl:stylesheet>
snippet template
<xsl:template match="${1:*}">${0}
</xsl:template>
snippet template named
<xsl:template name="${1:name}">${0}
</xsl:template>
snippet text
<xsl:text>${0}</xsl:text>
snippet value-of
<xsl:value-of select="${1:*}" />
snippet variable blank
<xsl:variable name="${1:name}">${0}
</xsl:variable>
snippet variable select
<xsl:variable select="${1:*}" />
snippet when
<xsl:when test="${1:test}">${0}
</xsl:when>
snippet with-param
<xsl:with-param name="${1:name}">${0}</xsl:with-param>
snippet with-param select
<xsl:with-param name="${1:name}" select="${0:*}" />
snippet apply-templates with-param
<xsl:apply-templates select="${1:*}">
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
</xsl:apply-templates>
snippet apply-templates sort-by
<xsl:apply-templates select="${1:*}">
<xsl:sort select="${2:node}" order="${3:ascending}" data-type="${4:text}">${5}
</xsl:apply-templates>
snippet apply-templates plain
<xsl:apply-templates select="${1:*}" />
snippet attribute blank
<xsl:attribute name="${1:name}">${2}</xsl:attribute>
snippet attribute value-of
<xsl:attribute name="${1:name}">
<xsl:value-of select="${2:*}" />
</xsl:attribute>
snippet call-template
<xsl:call-template name="${1:template}" />
snippet call-template with-param
<xsl:call-template name="${1:template}">
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
</xsl:call-template>
snippet choose
<xsl:choose>
<xsl:when test="${1:value}">
${2}
</xsl:when>
</xsl:choose>
snippet copy-of
<xsl:copy-of select="${1:*}" />
snippet for-each
<xsl:for-each select="${1:*}">${2}
</xsl:for-each>
snippet if
<xsl:if test="${1:test}">${2}
</xsl:if>
snippet import
<xsl:import href="${1:stylesheet}" />
snippet include
<xsl:include href="${1:stylesheet}" />
snippet otherwise
<xsl:otherwise>${0}
</xsl:otherwise>
snippet param
<xsl:param name="${1:name}">${2}
</xsl:param>
snippet stylesheet
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">${0}
</xsl:stylesheet>
snippet template
<xsl:template match="${1:*}">${0}
</xsl:template>
snippet template named
<xsl:template name="${1:name}">${0}
</xsl:template>
snippet text
<xsl:text>${0}</xsl:text>
snippet value-of
<xsl:value-of select="${1:*}" />
snippet variable blank
<xsl:variable name="${1:name}">${0}
</xsl:variable>
snippet variable select
<xsl:variable select="${1:*}" />
snippet when
<xsl:when test="${1:test}">${0}
</xsl:when>
snippet with-param
<xsl:with-param name="${1:name}">${0}</xsl:with-param>
snippet with-param select
<xsl:with-param name="${1:name}" select="${0:*}" />

View File

@@ -1,26 +1,26 @@
" Vim Syntax file for CON files
syn match SetLength /^\d\{3\}/ nextgroup=SetKeyword,SetKeywordMarked,SetKeywordInfoMarked
hi SetLength guifg=grey
syn match SetKeyword /\d\{4\}/ contained
hi SetKeyword guifg=lightgreen
" Visitations marked completely
syn match SetKeywordMarked /310[123]\|5000/ contained nextgroup=SetKeywordMarkedInfo
hi SetKeywordMarked gui=inverse guifg=lightgreen
" Treatments only mark treatment info
syn match SetKeywordInfoMarked /5001/ contained nextgroup=SetKeywordMarkedInfo
hi SetKeywordInfoMarked guifg=lightgreen
" mark keyword value
syn match SetKeywordMarkedInfo /..*/ contained
hi SetKeywordMarkedInfo gui=inverse
" Mark datasets like patient
syn match SetStart /^0138000/ nextgroup=SetType
syn match SetType /con0\|con9\|besa\|adt0\|adt9\|010[1-4]\|rvsa/ contained " 0101
hi SetStart guifg=white guibg=green
hi SetType guifg=white guibg=red
" Vim Syntax file for CON files
syn match SetLength /^\d\{3\}/ nextgroup=SetKeyword,SetKeywordMarked,SetKeywordInfoMarked
hi SetLength guifg=grey
syn match SetKeyword /\d\{4\}/ contained
hi SetKeyword guifg=lightgreen
" Visitations marked completely
syn match SetKeywordMarked /310[123]\|5000/ contained nextgroup=SetKeywordMarkedInfo
hi SetKeywordMarked gui=inverse guifg=lightgreen
" Treatments only mark treatment info
syn match SetKeywordInfoMarked /5001/ contained nextgroup=SetKeywordMarkedInfo
hi SetKeywordInfoMarked guifg=lightgreen
" mark keyword value
syn match SetKeywordMarkedInfo /..*/ contained
hi SetKeywordMarkedInfo gui=inverse
" Mark datasets like patient
syn match SetStart /^0138000/ nextgroup=SetType
syn match SetType /con0\|con9\|besa\|adt0\|adt9\|010[1-4]\|rvsa/ contained " 0101
hi SetStart guifg=white guibg=green
hi SetType guifg=white guibg=red