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 -- Options for AsciiDoc files, mainly used in diary situations
-- (pun intended) -- (pun intended)
vim.opt.textwidth = 80 vim.opt.textwidth = 80

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
runtime colors/lunaperche.vim runtime colors/lunaperche.vim
" fix VertSplit for lunaperche " fix VertSplit for lunaperche
hi VertSplit guifg=#aaaaaa 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/* -- load configurations files from lua/*
require('filetype') require('filetype')
require('options') require('options')
@@ -6,5 +13,7 @@ require('plugins')
require('colorscheme') require('colorscheme')
require('lsp') require('lsp')
require('keybindings') require('keybindings')
require('diary')
require('layout') require('layout')
if vim.loop.os_gethostname() == 'ccflow' then
require('diary')
end

View File

@@ -1,8 +1,8 @@
-- define your colorscheme here -- define your colorscheme here
local colorscheme = 'lunaperche-sl' local colorscheme = 'lunaperche-sl'
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not is_ok then if not is_ok then
vim.notify('colorscheme ' .. colorscheme .. ' not found!') vim.notify('colorscheme ' .. colorscheme .. ' not found!')
return return
end end

View File

@@ -1,109 +1,116 @@
local alpha = require 'alpha' local alpha = require 'alpha'
local dashboard = require 'alpha.themes.dashboard' local dashboard = require 'alpha.themes.dashboard'
_Gopts = { _Gopts = {
position = 'center', position = 'center',
hl = 'Type', hl = 'Type',
wrap = 'overflow', wrap = 'overflow',
} }
-- DASHBOARD HEADER -- DASHBOARD HEADER
local function getGreeting() local function getGreeting()
local tableTime = os.date '*t' local tableTime = os.date '*t'
local datetime = os.date ' %Y-%m-%d-%A  %H:%M:%S ' local datetime = os.date ' %Y-%m-%d-%A  %H:%M:%S '
local hour = tableTime.hour local hour = tableTime.hour
local greetingsTable = { local greetingsTable = {
[1] = ' Sleep well', [1] = ' Sleep well',
[2] = ' Good morning', [2] = ' Good morning',
[3] = ' Good afternoon', [3] = ' Good afternoon',
[4] = ' Good evening', [4] = ' Good evening',
[5] = '󰖔 Good night', [5] = '󰖔 Good night',
} }
local greetingIndex = 0 local greetingIndex = 0
if hour == 23 or hour < 7 then if hour == 23 or hour < 7 then
greetingIndex = 1 greetingIndex = 1
elseif hour < 12 then elseif hour < 12 then
greetingIndex = 2 greetingIndex = 2
elseif hour >= 12 and hour < 18 then elseif hour >= 12 and hour < 18 then
greetingIndex = 3 greetingIndex = 3
elseif hour >= 18 and hour < 21 then elseif hour >= 18 and hour < 21 then
greetingIndex = 4 greetingIndex = 4
elseif hour >= 21 then elseif hour >= 21 then
greetingIndex = 5 greetingIndex = 5
end end
return datetime .. ' ' .. greetingsTable[greetingIndex] return datetime .. ' ' .. greetingsTable[greetingIndex]
end end
local logo = [[ local logo = [[
 
████ ██████ █████ ██ ████ ██████ █████ ██
███████████ █████  ███████████ █████ 
█████████ ███████████████████ ███ ███████████ █████████ ███████████████████ ███ ███████████
█████████ ███ █████████████ █████ ██████████████ █████████ ███ █████████████ █████ ██████████████
█████████ ██████████ █████████ █████ █████ ████ █████ █████████ ██████████ █████████ █████ █████ ████ █████
███████████ ███ ███ █████████ █████ █████ ████ █████ ███████████ ███ ███ █████████ █████ █████ ████ █████
██████ █████████████████████ ████ █████ █████ ████ ██████ ██████ █████████████████████ ████ █████ █████ ████ ██████
]] ]]
local greeting = getGreeting() local greeting = getGreeting()
local marginBottom = 0 local marginBottom = 0
-- Split logo into lines -- Split logo into lines
local logoWidth = 0 local logoWidth = 0
for line in logo:gmatch '[^\n]+' do for line in logo:gmatch '[^\n]+' do
logoWidth = math.max(logoWidth, #line / 2) logoWidth = math.max(logoWidth, #line / 2)
end end
logoWidth = 75 -- code above does not work with utf8 strings in lua 5.1 logoWidth = 75 -- code above does not work with utf8 strings in lua 5.1
-- Calculate padding for centering the greeting -- Calculate padding for centering the greeting
local greetingWidth = #greeting - 3 local greetingWidth = #greeting - 3
local padding = math.floor((logoWidth - greetingWidth) / 2) local padding = math.floor((logoWidth - greetingWidth) / 2)
-- Generate spaces for padding -- Generate spaces for padding
local paddedGreeting = string.rep(' ', padding) .. greeting local paddedGreeting = string.rep(' ', padding) .. greeting
local userName = "You work as '" .. (vim.env.USER or vim.env.USERNAME) .. "'."
local userName = "You work as '" .. vim.env.USER .. "'."
-- Calculate padding for centering the username
-- Calculate padding for centering the username local userNameWidth = #userName
local userNameWidth = #userName local padding = math.floor((logoWidth - userNameWidth) / 2)
local padding = math.floor((logoWidth - userNameWidth) / 2) -- Generate spaces for padding
-- Generate spaces for padding local userNamePadded = string.rep(' ', padding) .. userName
local userNamePadded = string.rep(' ', padding) .. userName
-- Add margin lines below the padded greeting
-- Add margin lines below the padded greeting local margin = string.rep('\n', marginBottom * 5)
local margin = string.rep('\n', marginBottom * 5)
-- Concatenate logo, padded greeting, and margin
-- Concatenate logo, padded greeting, and margin local adjustedLogo = logo .. '\n' .. paddedGreeting .. '\n\n' .. userNamePadded .. '\n' .. margin
local adjustedLogo = logo .. '\n' .. paddedGreeting .. '\n\n' .. userNamePadded .. '\n' .. margin dashboard.section.header.val = vim.split(adjustedLogo, '\n')
dashboard.section.header.val = vim.split(adjustedLogo, '\n')
local buttons = {
dashboard.section.buttons.val = { dashboard.button('n', ' New file', ':ene <BAR> startinsert <CR>'),
dashboard.button('d', ' Diary Entry', '<cmd>Diary<CR>'), dashboard.button('s', ' Settings', '<cmd>WorkspacesOpen config-nvim<CR>'),
dashboard.button('n', ' New file', ':ene <BAR> startinsert <CR>'), dashboard.button('t', '[] Todo List', '<cmd>Org agenda t<CR>'),
dashboard.button('s', ' Settings', '<cmd>WorkspacesOpen config-nvim<CR>'), dashboard.button('u', '󱐥 Update plugins', '<cmd>Lazy update<CR>'),
dashboard.button('u', '󱐥 Update plugins', '<cmd>Lazy update<CR>'), dashboard.button('w', ' Workspaces', '<cmd>WorkspacesOpen<CR>'),
dashboard.button('w', ' Workspaces', '<cmd>WorkspacesOpen<CR>'), dashboard.button('q', '󰤆 Quit', '<cmd>qa<CR>'),
dashboard.button('q', '󰤆 Quit', '<cmd>qa<CR>'), }
}
if vim.loop.os_gethostname() == 'ccflow' then
-- dashboard.section.footer.val = greeting table.insert(buttons, 1,
dashboard.button('d', ' Diary Entry', '<cmd>Diary<CR>'))
vim.api.nvim_create_autocmd('User', { end
pattern = 'LazyVimStarted',
desc = 'Add Alpha dashboard footer', dashboard.section.buttons.val = buttons
once = true,
callback = function() -- dashboard.section.footer.val = greeting
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 ' } vim.api.nvim_create_autocmd('User', {
dashboard.section.header.opts.hl = 'DashboardFooter' pattern = 'LazyVimStarted',
pcall(vim.cmd.AlphaRedraw) desc = 'Add Alpha dashboard footer',
end, once = true,
}) callback = function()
local stats = require('lazy').stats()
dashboard.opts.opts.noautocmd = true local ms = math.floor(stats.startuptime * 100 + 0.5) / 100
alpha.setup(dashboard.opts) 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 { require("lualine").setup {
options = { options = {
icons_enabled = false, icons_enabled = false,
theme = 'papercolor_light', theme = 'papercolor_light',
component_separators = {}, component_separators = {},
section_separators = {}, section_separators = {},
disabled_filetypes = { disabled_filetypes = {
statusline = {}, statusline = {},
winbar = { "neo-tree" }, winbar = { "neo-tree" },
}, },
ignore_focus = {}, ignore_focus = {},
always_divide_middle = true, always_divide_middle = true,
globalstatus = false, globalstatus = false,
refresh = { refresh = {
statusline = 1000, statusline = 1000,
tabline = 1000, tabline = 1000,
winbar = 1000, winbar = 1000,
} }
}, },
sections = { sections = {
lualine_a = { { 'filename', path = 1, shorting_target = 50 } }, lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
lualine_b = { 'branch', 'diff', 'diagnostics' }, lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {}, lualine_c = {},
lualine_x = { 'encoding', 'fileformat', 'filetype', 'lsp_status' }, lualine_x = { 'encoding', 'fileformat', 'filetype', 'lsp_status' },
lualine_y = { 'filesize' }, lualine_y = { 'filesize' },
lualine_z = { 'progress', 'location' } lualine_z = { 'progress', 'location' }
}, },
inactive_sections = { inactive_sections = {
lualine_a = { { 'filename', path = 1, shorting_target = 50 } }, lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
lualine_b = {}, lualine_b = {},
lualine_c = {}, lualine_c = {},
-- lualine_x = { 'encoding', 'fileformat', 'filetype' }, -- lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_x = {}, lualine_x = {},
lualine_y = { 'filesize' }, lualine_y = { 'filesize' },
lualine_z = { 'location' } lualine_z = { 'location' }
}, },
tabline = {}, tabline = {},
winbar = {}, -- formerly breadcrumb here winbar = {}, -- formerly breadcrumb here
inactive_winbar = {}, inactive_winbar = {},
extensions = {} extensions = {}
} }

View File

@@ -1,24 +1,24 @@
local diary_open = function(opts) local diary_open = function(opts)
local date = opts.args ~= '' and opts.args or os.date('%Y-%m-%d') 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 year, month = date:match('(%d%d%d%d)-(%d%d)')
local folder = string.format('~/.diary/asciidoc/%s', year) local folder = vim.fs.joinpath(vim.env.HOME, string.format('.diary/asciidoc/%s', year))
vim.fn.mkdir(folder, "p") vim.fn.mkdir(folder, "p")
local file = string.format('%s/diary-%s-%s.adoc', folder, year, month) local file = string.format('%s/diary-%s-%s.adoc', folder, year, month)
print("file is:", file) print("file is:", file)
vim.cmd('e ' .. file) vim.cmd('e ' .. file)
vim.cmd('normal! G') -- go to end of 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 -- NOTE.2025-06-08 [1] and [2] should be replaced with snippet name, but I
-- don't know how -- neither do grok nor chatgpt ... -- don't know how -- neither do grok nor chatgpt ...
local snips = require('luasnip') local snips = require('luasnip')
local asnippets = snips.get_snippets('asciidoc') local asnippets = snips.get_snippets('asciidoc')
if vim.fn.getfsize(file) == 0 then if vim.fn.getfsize(file) == 0 then
snips.snip_expand(asnippets[1]) snips.snip_expand(asnippets[1])
vim.cmd('normal! G') vim.cmd('normal! G')
end end
vim.cmd('normal! 3o') -- insert some newlines before new entry vim.cmd('normal! 3o') -- insert some newlines before new entry
snips.snip_expand(asnippets[2]) snips.snip_expand(asnippets[2])
end end
vim.api.nvim_create_user_command("Diary", diary_open, { nargs = '?' }) vim.api.nvim_create_user_command("Diary", diary_open, { nargs = '?' })

View File

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

View File

@@ -1,15 +1,15 @@
-- custom defined functions -- custom defined functions
-- Return the currently, visually selected text range -- Return the currently, visually selected text range
function SL_get_visual_selection() function SL_get_visual_selection()
vim.cmd([[ execute "normal! \<ESC>" ]]) vim.cmd([[ execute "normal! \<ESC>" ]])
local s_start = vim.fn.getcharpos("'<") local s_start = vim.fn.getcharpos("'<")
local s_end = vim.fn.getcharpos("'>") local s_end = vim.fn.getcharpos("'>")
vim.cmd([[ execute "normal! gv" ]]) vim.cmd([[ execute "normal! gv" ]])
local current_buffer = vim.api.nvim_get_current_buf() 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, 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], {}) 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]) -- print("region might be", current_buffer, s_start[2], s_start[3], s_end[2], s_end[3])
return table.concat(r, "\n") return table.concat(r, "\n")
end end

View File

@@ -1,125 +1,129 @@
-- Setup fzf-lua keybindings and some other searches -- Setup fzf-lua keybindings and some other searches
local fzf = require('fzf-lua') local fzf = require('fzf-lua')
vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" }) 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>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>fT', fzf.treesitter, { desc = "Treesitter symbols" })
vim.keymap.set('n', '<leader>fc', fzf.commands, { desc = "Commands" }) 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>ff', fzf.files, { desc = "Find file" })
vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" }) 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>fm', fzf.manpages, { desc = "Manpages" })
vim.keymap.set('n', '<leader>fr', fzf.resume, { desc = "Resume last search" }) 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>fs', fzf.blines, { desc = "Search buffer" })
vim.keymap.set('n', '<leader>f=', fzf.changes, { desc = "Changes" }) 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>fR', fzf.registers, { desc = "Registers" })
vim.keymap.set('n', '<leader>fo', fzf.nvim_options, { desc = "NVim Options" }) 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>ft', ":TodoFzfLua<CR>", { desc = "Todos" })
vim.keymap.set('n', '<leader>fl', fzf.git_bcommits, { desc = "Git buffer log" }) vim.keymap.set('n', '<leader>fl', fzf.git_bcommits, { desc = "Git buffer log" })
-- use fzf buffer lines as default search -- use fzf buffer lines as default search
vim.keymap.set('n', '<C-/>', fzf.blines, { desc = "Search buffer" }) vim.keymap.set('n', '<C-/>', fzf.blines, { desc = "Search buffer" })
vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" }) vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" })
-- open file manager and git -- open file manager and git
vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Neogit" }) 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>T', ":Neotree reveal<CR>", { desc = "Neotree Files" })
vim.keymap.set('n', '<leader>F', ":Fyler kind=split_left<CR>", { desc = "Fyler Files" }) vim.keymap.set('n', '<leader>F', ":Fyler kind=split_left<CR>", { desc = "Fyler Files" })
-- calendar -- 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 -split=horizontal -position=below -height=12<CR>",
vim.keymap.set('n', '<leader>C', ":Calendar -view=year -split=vertical -width=27<CR>", { desc = "Show calendar right" }) { 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 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" }) if vim.loop.os_gethostname() == 'ccflow' then
-- Open org file folder in neotree
-- toggle colorscheme between dark and light vim.keymap.set('n', '<leader>of', ':silent :Neotree dir=/home/saschal/Documents/Eigene\\ (Briefe\\ etc.)/org<cr>',
vim.keymap.set('n', '<leader>m', function() { desc = "Open org folder" })
if vim.opt.background:get() == "dark" then end
vim.o.background = "light"
else -- toggle colorscheme between dark and light
vim.o.background = "dark" vim.keymap.set('n', '<leader>m', function()
end if vim.opt.background:get() == "dark" then
end, { desc = "Toggle dark/light mode" }) vim.o.background = "light"
else
-- vim.o.background = "dark"
-- configure workspaces end
-- also add a custom picker to fzf end, { desc = "Toggle dark/light mode" })
--
local workspaces = require('workspaces') --
local workspaces_fzf_picker = function(opts) -- configure workspaces
local fzf_lua = require('fzf-lua') -- also add a custom picker to fzf
opts = opts or {} --
opts.prompt = "Workspaces> " local workspaces = require('workspaces')
opts.actions = { local workspaces_fzf_picker = function(opts)
['default'] = function(selected) local fzf_lua = require('fzf-lua')
workspaces.open(selected[1]) opts = opts or {}
end opts.prompt = "Workspaces> "
} opts.actions = {
fzf_lua.fzf_exec(function(fzf_cb) ['default'] = function(selected)
-- NOP workspaces.open(selected[1])
local ws = workspaces.get() end
ws = ws or {} }
for i = 1, #ws do fzf_lua.fzf_exec(function(fzf_cb)
fzf_cb(ws[i].name) -- NOP
end local ws = workspaces.get()
fzf_cb() -- EOF ws = ws or {}
end, opts) for i = 1, #ws do
end fzf_cb(ws[i].name)
vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" }) end
fzf_cb() -- EOF
------------------------------------------ end, opts)
-- end
-- Window layout save and restore vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" })
--
------------------------------------------ ------------------------------------------
--
local layout = require('layout') -- Window layout save and restore
vim.keymap.set('n', '<leader>ss', function() --
layout.save('default') ------------------------------------------
print("Window layout saved")
end, { desc = "Save window layout" }) local layout = require('layout')
vim.keymap.set('n', '<leader>sr', function() vim.keymap.set('n', '<leader>ss', function()
layout.restore('default') layout.save('default')
print("Window layout restored") print("Window layout saved")
end, { desc = "Restore window layout" }) end, { desc = "Save window layout" })
vim.keymap.set('n', '<leader>sr', function()
------------------------------------------ layout.restore('default')
-- print("Window layout restored")
-- Word higlighting end, { desc = "Restore window layout" })
--
------------------------------------------ ------------------------------------------
local mywords = require('mywords') --
vim.keymap.set('n', '<space>mm', mywords.hl_toggle, { desc = "Highlight current word" }) -- Word higlighting
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" }) ------------------------------------------
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" }) -- Moving lines up and down
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" }) 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" })
-- Shortcuts which are known from Emacs vim.keymap.set('i', '<M-Down>', "<c-o>:m +1<cr>", { desc = "Move current line down" })
--
------------------------------------------ ------------------------------------------
vim.keymap.set('n', '<space>q', "gwap", { desc = "Wrap paragraph" }) --
vim.keymap.set('n', '<esc><esc>', ":silent! nohls<CR>", { desc = "Clear search" }) -- Shortcuts which are known from Emacs
vim.keymap.set('i', '<c-Del>', '<c-o>dW', {desc = "Delete word right" }) --
------------------------------------------
-- horizontally scroll with mouse vim.keymap.set('n', '<space>q', "gwap", { desc = "Wrap paragraph" })
vim.keymap.set('n', '<S-ScrollWheelUp>', 'zh') vim.keymap.set('n', '<esc><esc>', ":silent! nohls<CR>", { desc = "Clear search" })
vim.keymap.set('n', '<S-ScrollWheelDown>', 'zl') vim.keymap.set('i', '<c-Del>', '<c-o>dW', { desc = "Delete word right" })
vim.keymap.set('i', '<S-ScrollWheelUp>', '<c-o>zh') -- horizontally scroll with mouse
vim.keymap.set('i', '<S-ScrollWheelDown>', '<c-o>zl') 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 -- save and restore current window layout
-- inspired by: -- inspired by:
-- - https://github.com/dedowsdi/.vim/blob/master/autoload/ddd/layout.vim -- - https://github.com/dedowsdi/.vim/blob/master/autoload/ddd/layout.vim
-- - https://vi.stackexchange.com/a/22545/53081 -- - https://vi.stackexchange.com/a/22545/53081
-- --
-- added cursor position handling -- added cursor position handling
local M = {} local M = {}
local layouts = {} local layouts = {}
local resize_cmds = {} local resize_cmds = {}
function M.save(name) function M.save(name)
layouts[name] = vim.fn.winlayout() layouts[name] = vim.fn.winlayout()
resize_cmds[name] = vim.fn.winrestcmd() resize_cmds[name] = vim.fn.winrestcmd()
M.add_buf_to_layout(layouts[name]) M.add_buf_to_layout(layouts[name])
end end
function M.add_buf_to_layout(layout) function M.add_buf_to_layout(layout)
if layout[1] == "leaf" then if layout[1] == "leaf" then
local win_id = layout[2] local win_id = layout[2]
table.insert(layout, vim.fn.winbufnr(win_id)) table.insert(layout, vim.fn.winbufnr(win_id))
table.insert(layout, vim.api.nvim_win_get_cursor(win_id)) table.insert(layout, vim.api.nvim_win_get_cursor(win_id))
else else
for _, child_layout in ipairs(layout[2]) do for _, child_layout in ipairs(layout[2]) do
M.add_buf_to_layout(child_layout) M.add_buf_to_layout(child_layout)
end end
end end
end end
function M.restore(name) function M.restore(name)
if not layouts[name] then if not layouts[name] then
return return
end end
-- Create clean window -- Create clean window
vim.cmd("new") vim.cmd("new")
vim.cmd("wincmd o") vim.cmd("wincmd o")
-- Recursively restore buffers and cursor positions -- Recursively restore buffers and cursor positions
M.apply_layout(layouts[name], name) M.apply_layout(layouts[name], name)
-- Resize -- Resize
vim.cmd(resize_cmds[name]) vim.cmd(resize_cmds[name])
end end
function M.apply_layout(layout, name) function M.apply_layout(layout, name)
if layout[1] == "leaf" then if layout[1] == "leaf" then
-- Load buffer for leaf -- Load buffer for leaf
if vim.fn.bufexists(layout[3]) == 1 then if vim.fn.bufexists(layout[3]) == 1 then
vim.cmd(string.format("b %d", layout[3])) vim.cmd(string.format("b %d", layout[3]))
-- Restore cursor position -- Restore cursor position
vim.api.nvim_win_set_cursor(vim.fn.win_getid(), layout[4]) vim.api.nvim_win_set_cursor(vim.fn.win_getid(), layout[4])
end end
else else
-- Split cols or rows, split n-1 times -- Split cols or rows, split n-1 times
local split_method = layout[1] == "col" and "rightbelow split" or "rightbelow vsplit" local split_method = layout[1] == "col" and "rightbelow split" or "rightbelow vsplit"
local wins = { vim.fn.win_getid() } local wins = { vim.fn.win_getid() }
for i = 2, #layout[2] do for i = 2, #layout[2] do
vim.cmd(split_method) vim.cmd(split_method)
table.insert(wins, vim.fn.win_getid()) table.insert(wins, vim.fn.win_getid())
end end
-- Recursive into child windows -- Recursive into child windows
for index, win_id in ipairs(wins) do for index, win_id in ipairs(wins) do
vim.fn.win_gotoid(win_id) vim.fn.win_gotoid(win_id)
M.apply_layout(layout[2][index], name) M.apply_layout(layout[2][index], name)
end end
end end
end end
return M return M

View File

@@ -1,128 +1,134 @@
-- attach using autocommand and setup keybindings -- attach using autocommand and setup keybindings
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('sl.lsp', {}), group = vim.api.nvim_create_augroup('sl.lsp', {}),
callback = function(args) callback = function(args)
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = args.buf } 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', 'K', vim.lsp.buf.hover, { desc = "LSP show signature", unpack(bufopts) })
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder,
{ desc = "Workspace add folder", unpack(bufopts) }) { desc = "Workspace add folder", unpack(bufopts) })
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder,
{ desc = "Workspace remove folder", unpack(bufopts) }) { desc = "Workspace remove folder", unpack(bufopts) })
vim.keymap.set('n', '<space>wl', function() vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, { desc = "Workspace list folders", unpack(bufopts) }) 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>rn', vim.lsp.buf.rename, { desc = "LSP Rename", unpack(bufopts) })
vim.keymap.set("n", "<space>f", function() vim.keymap.set("n", "<space>f", function()
vim.lsp.buf.format({ async = true }) vim.lsp.buf.format({ async = true })
end, { desc = "LSP Format buffer", unpack(bufopts) }) 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("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" }) vim.keymap.set("v", "<space>f", LSPRangeFormatFunction, { desc = "LSP Format region" })
-- 2024-09-09 - some ccflow commands for diagnostics, symbols and code actions -- 2024-09-09 - some ccflow commands for diagnostics, symbols and code actions
local fzf = require('fzf-lua') 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_document, { desc = "Document diagnostics" })
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" }) vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
vim.keymap.set('n', '<space>e', function() vim.keymap.set('n', '<space>e', function()
local new_config = not vim.diagnostic.config().virtual_lines local new_config = not vim.diagnostic.config().virtual_lines
vim.diagnostic.config({ virtual_lines = new_config }) vim.diagnostic.config({ virtual_lines = new_config })
end, { desc = "Virtual line diagnostics" }) end, { desc = "Virtual line diagnostics" })
vim.keymap.set('n', '<space>E', vim.diagnostic.open_float, { desc = "Popup 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>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>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_prev, { desc = "Previous diagnostics" })
vim.keymap.set('n', '<space>]', vim.diagnostic.goto_next, { desc = "Previous diagnostics" }) vim.keymap.set('n', '<space>]', vim.diagnostic.goto_next, { desc = "Previous diagnostics" })
local gitsigns = require('gitsigns') local gitsigns = require('gitsigns')
vim.keymap.set('n', '<space>=l', ":NeogitLogCurrent<CR>", { desc = "Neogit: log for this file" }) 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>==', 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>=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>=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>=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>=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.prev_hunk, { desc = "Git previous hunk" })
vim.keymap.set('n', '<space>=]', gitsigns.next_hunk, { desc = "Git next 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>=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>=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>=r', gitsigns.reset_hunk, { desc = "Git reset hunk" })
vim.keymap.set('n', '<space>=s', gitsigns.stage_hunk, { desc = "Git stage 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, vim.keymap.set('v', '<space>=s', function() gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end,
{ desc = "Git stage hunk" }) { desc = "Git stage hunk" })
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) -- 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_references, { desc = "Find References" })
vim.keymap.set('n', '<C-.>', fzf.lsp_definitions, { desc = "Find References" }) vim.keymap.set('n', '<C-.>', fzf.lsp_definitions, { desc = "Find References" })
end end
}) })
-- lsp format selected range -- lsp format selected range
function LSPRangeFormatFunction() function LSPRangeFormatFunction()
vim.lsp.buf.format({ vim.lsp.buf.format({
async = true, async = true,
range = { range = {
["start"] = vim.api.nvim_buf_get_mark(0, "<"), ["start"] = vim.api.nvim_buf_get_mark(0, "<"),
["end"] = vim.api.nvim_buf_get_mark(0, ">"), ["end"] = vim.api.nvim_buf_get_mark(0, ">"),
} }
}) })
end end
local enable_this_lsp = {}
-- VUE and Typescript as of vue-language-server 3.0.x if vim.loop.os_gethostname() == 'ccflow' then
-- taken from: -- VUE and Typescript as of vue-language-server 3.0.x
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#vtsls -- taken from:
local vue_language_server_path = '/home/saschal/.config/yarn/global/node_modules' -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#vtsls
local vue_plugin = { local vue_language_server_path = '/home/saschal/.config/yarn/global/node_modules'
name = '@vue/typescript-plugin', local vue_plugin = {
location = vue_language_server_path, name = '@vue/typescript-plugin',
languages = { 'vue' }, location = vue_language_server_path,
configNamespace = 'typescript', languages = { 'vue' },
} configNamespace = 'typescript',
local vtsls_config = { }
settings = { local vtsls_config = {
vtsls = { settings = {
tsserver = { vtsls = {
globalPlugins = { tsserver = {
vue_plugin, globalPlugins = {
}, vue_plugin,
}, },
}, },
}, },
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, },
} filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
vim.lsp.config('vtsls', vtsls_config) }
vim.lsp.config('vtsls', vtsls_config)
-- enable this list of lsps
local enable_this_lsp = { -- enable this list of lsps
'vue_ls', enable_this_lsp = {
'vtsls', 'vue_ls',
'gopls', 'vtsls',
'bashls', 'gopls',
'html', 'bashls',
'lua_ls', 'html',
'jsonls', -- arch extra: vscode-json-languageserver 'lua_ls',
'kotlin_lsp', -- arch aur: kotlin-lsp-bin 'jsonls', -- arch extra: vscode-json-languageserver
'lemminx', -- arch aur: lemminx 'kotlin_lsp', -- arch aur: kotlin-lsp-bin
'clangd', 'lemminx', -- arch aur: lemminx
'basedpyright', 'clangd',
'wgsl_analyzer', 'basedpyright',
} 'wgsl_analyzer',
}
for l in pairs(enable_this_lsp) do else
vim.lsp.enable(enable_this_lsp[l]) -- any lsp which should be enabled in all situations
end enable_this_lsp = {
}
end
-- add autoformat to Dioxus projects
vim.api.nvim_create_autocmd("BufWritePost", { for l in pairs(enable_this_lsp) do
pattern = "*.rs", vim.lsp.enable(enable_this_lsp[l])
callback = function() end
local cwd = vim.lsp.buf.list_workspace_folders()
if not (cwd == nil) then
if vim.fn.filereadable(cwd[1] .. "/Dioxus.toml") == 1 then -- add autoformat to Dioxus projects
local command = "dx fmt --file %" vim.api.nvim_create_autocmd("BufWritePost", {
vim.cmd("silent ! " .. command) pattern = "*.rs",
-- vim.notify(command) callback = function()
end local cwd = vim.lsp.buf.list_workspace_folders()
end if not (cwd == nil) then
end, 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 -- Global settings
-- which I have forgotten --
-- ---------------------------------------------------
--------------------------------------------------
-- global
-- Hint: use `:h <option>` to figure out the meaning if needed
vim.opt.clipboard = 'unnamedplus' -- use system clipboard sl_opt = {}
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
-- this is specific for a machine
-- Tab if vim.loop.os_gethostname() == 'ccflow' then
vim.opt.tabstop = 2 -- number of visual spaces per TAB sl_opt = {
vim.opt.softtabstop = 2 -- number of spaces in tab when editing org_agenda_files = '~/Documents/Eigene (Briefe etc.)/org/*.org',
vim.opt.shiftwidth = 2 -- insert 4 spaces on a tab org_default_notes_file = '~/Documents/Eigene (Briefe etc.)/org/refile.org',
vim.opt.expandtab = true -- tabs are spaces, mainly because of python and because it is consistent org_roam_folder = '~/Documents/Eigene (Briefe etc.)/org/roam',
}
-- UI config else
vim.opt.number = true -- show absolute number sl_opt = {
vim.opt.relativenumber = false -- add numbers to each line on the left side org_agenda_files = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles/*.org',
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally org_default_notes_file = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles/refile.org',
vim.opt.guicursor = "" .. -- cursor highlight group needs to be Cursor to have lunaperche have a proper light cursor org_roam_folder = '~/OneDrive - Stadt Rosenheim/Desktop/orgfiles/roam',
"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 end
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 -- Some general setup taken from some tutorial
vim.opt.winborder = 'rounded' -- UI borders are rounded -- which I have forgotten
--
-- Searching --------------------------------------------------
vim.opt.incsearch = true -- search as characters are entered
vim.opt.hlsearch = true -- do not highlight matches -- Hint: use `:h <option>` to figure out the meaning if needed
vim.opt.ignorecase = true -- ignore case in searches by default vim.opt.clipboard = 'unnamedplus' -- use system clipboard
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered 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
-- General text editing and cursor movements 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
-- Wrapping movements and long lines -- UI config
vim.opt.whichwrap = "b,s,<,>,[,]" -- wrap backspace, space and left-right cursor keys vim.opt.number = true -- show absolute number
vim.opt.wrap = false vim.opt.relativenumber = false -- add numbers to each line on the left side
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
-- Spelling vim.opt.guicursor = "" .. -- cursor highlight group needs to be Cursor to have lunaperche have a proper light cursor
vim.opt.spell = true "n-v-c-sm:block-Cursor,i-ci-ve:ver25-Cursor,r-cr-o:hor20,t:block-blinkon500-blinkoff500-Cursor"
vim.opt.spelllang = "de,en" 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
-- calendar.vim options vim.opt.showtabline = 0 -- never show top line with tabs, not used anyways
-- vim.opt.winborder = 'rounded' -- UI borders are rounded
--------------------------------------------------
-- :Calendar -split=horizontal -position=below -height=12 -- Searching
vim.opt.incsearch = true -- search as characters are entered
vim.g.calendar_first_day = "monday" vim.opt.hlsearch = true -- do not highlight matches
vim.g.calendar_view = "year" vim.opt.ignorecase = true -- ignore case in searches by default
vim.g.calendar_week_number = true vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
--------------------------------------------------
-- --------------------------------------------------
-- Other options --
-- -- General text editing and cursor movements
-------------------------------------------------- --
--------------------------------------------------
vim.opt.shortmess = vim.opt.shortmess + 'I'
-- 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 -- these are already defined elsewhere, but LSP does not recognize that
-- doc says luasnip.config.snip_env -- doc says luasnip.config.snip_env
local ls = require("luasnip") local ls = require("luasnip")
local s = ls.snippet local s = ls.snippet
local sn = ls.snippet_node local sn = ls.snippet_node
local isn = ls.indent_snippet_node local isn = ls.indent_snippet_node
local t = ls.text_node local t = ls.text_node
local i = ls.insert_node local i = ls.insert_node
local f = ls.function_node local f = ls.function_node
local c = ls.choice_node local c = ls.choice_node
local d = ls.dynamic_node local d = ls.dynamic_node
local r = ls.restore_node local r = ls.restore_node
local events = require("luasnip.util.events") local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer") local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras") local extras = require("luasnip.extras")
local l = extras.lambda local l = extras.lambda
local rep = extras.rep local rep = extras.rep
local p = extras.partial local p = extras.partial
local m = extras.match local m = extras.match
local n = extras.nonempty local n = extras.nonempty
local dl = extras.dynamic_lambda local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions") local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types") local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key local k = require("luasnip.nodes.key_indexer").new_key
-- ensure current locale is used to format dates -- ensure current locale is used to format dates
local curlang = os.getenv("LANG") local curlang = os.getenv("LANG")
os.setlocale(curlang) os.setlocale(curlang)
return { return {
-- = Oktober 2024 -- = Oktober 2024
-- :toc: -- :toc:
-- :numbered!: -- :numbered!:
-- --
-- <cursor> -- <cursor>
s("diahead", s("diahead",
{ {
t "= ", t "= ",
f(function() return os.date("%0B %Y") end), f(function() return os.date("%0B %Y") end),
t({ "", "", }), t({ "", "", }),
t({ ":toc:", "" }), t({ ":toc:", "" }),
t({ ":numbered!:", "" }), t({ ":numbered!:", "" }),
t({ "", "", }), t({ "", "", }),
} }
), ),
-- == 7. Oktober, 11:14, Montag -- == 7. Oktober, 11:14, Montag
-- --
-- <cursor> -- <cursor>
s("diaentry", s("diaentry",
{ {
t "== ", t "== ",
f(function() return os.date("%e. %0B, %H:%M, %A") end), f(function() return os.date("%e. %0B, %H:%M, %A") end),
t({ "", "", }), t({ "", "", }),
t({ "", "", }), t({ "", "", }),
} }
), ),
} }
-- --

View File

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

View File

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

View File

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

View File

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

View File

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