Compare commits
10 Commits
c80752ebea
...
98149a4b8f
| Author | SHA1 | Date | |
|---|---|---|---|
| 98149a4b8f | |||
| fab5a97e0c | |||
| 151a7e5833 | |||
| 7ffd390cb4 | |||
| e82602334e | |||
| de68c1e748 | |||
| 9e86ac8425 | |||
| 098b3c055e | |||
| a0b9561e10 | |||
| e9ef076ce5 |
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp-rpncalc": { "branch": "master", "commit": "3d82861b41c54cb0b3c2c513563e1d8758c92625" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||
"fzf-lua": { "branch": "main", "commit": "f513524561060f2b9e3bd6d36ff046bfa03ca114" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" },
|
||||
"lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
|
||||
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
|
||||
"mini.icons": { "branch": "main", "commit": "2d89252993fec829b24720097a687412d10f6c85" },
|
||||
"neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" },
|
||||
"neogit": { "branch": "master", "commit": "9959b58a897036ce89d47385021db1f716613399" },
|
||||
"nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "aaec5d049af99e7b975bdf68aca582f1aa91b338" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "2b2ac302324f4cd2194c5dcaa59332b65e1c6403" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "9154484705968658e9aab2b894d1b2a64bf9f83d" },
|
||||
"orgmode": { "branch": "master", "commit": "a006c9318132d51d3b7058cf2a8cc557c7fa4f22" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
|
||||
"vim-table-mode": { "branch": "master", "commit": "e4365bde024f73e205eefa2fb78e3029ddb92ea9" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "fb070344402cfc662299d9914f5546d840a22126" },
|
||||
"workspaces.nvim": { "branch": "master", "commit": "0b03d3f2ffe38729b1792905ec447405ed76cb6e" }
|
||||
}
|
||||
@@ -1,29 +1,33 @@
|
||||
-- Setup fzf-lua keybindings and some other searches
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<leader>ff', fzf.files, { desc = "Find file" })
|
||||
vim.keymap.set('n', '<leader>fs', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" })
|
||||
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>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>b', fzf.buffers, { desc = "Buffers" })
|
||||
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>ft', ":TodoFzfLua<CR>", { desc = "Todos" })
|
||||
|
||||
-- use fzf buffer lines as default search
|
||||
vim.keymap.set('n', '/', 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" })
|
||||
|
||||
-- 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 = "File Manager" })
|
||||
|
||||
-- calendar
|
||||
vim.keymap.set('n', '<leader>c', ":Calendar -split=horizontal -position=below -height=12<CR>", { desc = "Show calendar" })
|
||||
|
||||
--
|
||||
-- configure workspaces
|
||||
-- also add a custom picker to fzf
|
||||
--
|
||||
local workspaces = require('workspaces')
|
||||
workspaces_fzf_picker = function(opts)
|
||||
local workspaces_fzf_picker = function(opts)
|
||||
local fzf_lua = require('fzf-lua')
|
||||
opts = opts or {}
|
||||
opts.prompt = "Workspaces> "
|
||||
@@ -42,7 +46,7 @@ workspaces_fzf_picker = function(opts)
|
||||
fzf_cb() -- EOF
|
||||
end, opts)
|
||||
end
|
||||
vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" } )
|
||||
vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" })
|
||||
|
||||
------------------------------------------
|
||||
--
|
||||
@@ -60,5 +64,13 @@ vim.keymap.set('n', '<space>mc', mywords.uhl_all, { desc = "Clear all highlights
|
||||
-- Shortcuts which are known from Emacs
|
||||
--
|
||||
------------------------------------------
|
||||
vim.keymap.set('n', '<C-W>1', ":wincmd o<CR>", { desc = "Win: close others" })
|
||||
vim.keymap.set('n', '<C-W>0', ":only<CR>", { desc = "Win: close current" })
|
||||
vim.keymap.set('n', '<C-W>0', ":hide<CR>", { desc = "Win: close current" })
|
||||
vim.keymap.set('n', '<C-W>1', ":only<CR>", { desc = "Win: close others" })
|
||||
vim.keymap.set('n', '<C-W>2', ":split<CR>", { desc = "Win: split horizontally" })
|
||||
vim.keymap.set('n', '<C-W>2', ":vsplit<CR>", { desc = "Win: split vertically" })
|
||||
vim.keymap.set('n', '<space>q', "gwap", { desc = "Wrap paragraph" })
|
||||
vim.keymap.set('n', '<esc><esc>', ":silent! nohls<CR>", { desc = "Clear search" })
|
||||
|
||||
-- horizontally scroll with mouse
|
||||
vim.keymap.set('n', '<S-ScrollWheelUp>', 'zh')
|
||||
vim.keymap.set('n', '<S-ScrollWheelDown>', 'zl')
|
||||
|
||||
56
lua/lsp.lua
56
lua/lsp.lua
@@ -13,7 +13,7 @@ require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'pylsp',
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
-- 'rust_analyzer', -- handled by rust mrcjkb/rustaceanvim
|
||||
'yamlls',
|
||||
'ts_ls',
|
||||
'gopls',
|
||||
@@ -22,54 +22,53 @@ require('mason-lspconfig').setup({
|
||||
},
|
||||
})
|
||||
|
||||
-- Customized on_attach function
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Popup diagnostics" })
|
||||
-- 2024-09-23 - currently unused
|
||||
-- vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, 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,
|
||||
{ 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, bufopts)
|
||||
-- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
-- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, 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>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, bufopts)
|
||||
end, { desc = "LSP Format buffer", unpack(bufopts) })
|
||||
|
||||
-- 2024-09-09 - some ccflow commands
|
||||
|
||||
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', 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" })
|
||||
|
||||
local gitsigns = require('gitsigns')
|
||||
vim.keymap.set('n', '<space>==', gitsigns.preview_hunk_inline, { desc = "Git hunk preview" })
|
||||
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>=d', gitsigns.diffthis, { desc = "Git diff this" })
|
||||
vim.keymap.set('n', '<space>=D', function() gitsigns.diffthis('~') end, { desc = "Git diff this (~)" })
|
||||
vim.keymap.set('n', '<space>=s', gitsigns.stage_hunk, { desc = "Git stage hunk" })
|
||||
vim.keymap.set('n', '<space>=b', gitsigns.blame_line, { desc = "Git blame line" })
|
||||
vim.keymap.set('n', '<space>=B', gitsigns.blame, { desc = "Git blame file" })
|
||||
|
||||
-- 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
|
||||
|
||||
-- Set different settings for different languages' LSP
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
|
||||
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
||||
-- - the settings table is sent to the LSP
|
||||
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
|
||||
@@ -108,3 +107,12 @@ require('mason-lspconfig').setup_handlers({
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- use on_attach to get lsp related shortcuts
|
||||
vim.g.rustaceanvim = {
|
||||
-- LSP configuration
|
||||
server = {
|
||||
on_attach = on_attach
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||
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
|
||||
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
|
||||
@@ -46,6 +46,17 @@ vim.opt.wrap = false
|
||||
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
|
||||
|
||||
218
lua/plugins.lua
218
lua/plugins.lua
@@ -12,17 +12,10 @@ end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
-- Vscode-like pictograms
|
||||
{
|
||||
"onsails/lspkind.nvim",
|
||||
event = { "VimEnter" },
|
||||
},
|
||||
|
||||
-- Auto-completion engine
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"lspkind.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
||||
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
||||
"hrsh7th/cmp-path", -- path auto-completion
|
||||
@@ -49,12 +42,24 @@ require("lazy").setup({
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
-- Nice plugin to show what LSPs are doing in the background (and others
|
||||
-- using $/progress and vim.notify())
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
opts = {
|
||||
-- options
|
||||
},
|
||||
},
|
||||
|
||||
-- show lsp signature while coding
|
||||
{
|
||||
"ray-x/lsp_signature.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {},
|
||||
config = function(_, opts) require 'lsp_signature'.setup(opts) end
|
||||
opts = {
|
||||
bind = true,
|
||||
floating_window = false,
|
||||
},
|
||||
},
|
||||
|
||||
-- neogit setup
|
||||
@@ -81,6 +86,7 @@ require("lazy").setup({
|
||||
require('orgmode').setup({
|
||||
org_agenda_files = '~/orgfiles/**/*',
|
||||
org_default_notes_file = '~/orgfiles/refile.org',
|
||||
org_todo_keywords = {'TODO(t)', 'STARTED(s)', 'PLANNED(p)', '|', 'DONE(d)', 'UNPLANNED(u)' },
|
||||
})
|
||||
|
||||
-- NOTE: If you are using nvim-treesitter with ~ensure_installed = "all"~ option
|
||||
@@ -92,6 +98,9 @@ require("lazy").setup({
|
||||
end,
|
||||
},
|
||||
|
||||
-- comfortable table editing, esp. used in orgmode
|
||||
{ 'dhruvasagar/vim-table-mode' },
|
||||
|
||||
-- fzf-lua
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
@@ -105,7 +114,7 @@ require("lazy").setup({
|
||||
end
|
||||
},
|
||||
|
||||
-- whichkey
|
||||
-- which-key
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
@@ -159,6 +168,34 @@ require("lazy").setup({
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
config = function()
|
||||
-- an alternative might be:
|
||||
-- https://github.com/nvim-treesitter/nvim-treesitter-context
|
||||
local function breadcrumb()
|
||||
local result = require 'nvim-treesitter'.statusline(
|
||||
{
|
||||
type_patterns = {
|
||||
"class",
|
||||
"impl",
|
||||
"function",
|
||||
"method",
|
||||
"import",
|
||||
"for",
|
||||
"if",
|
||||
"while",
|
||||
"variable",
|
||||
"comment",
|
||||
},
|
||||
separator = " ▶ "
|
||||
}
|
||||
)
|
||||
if result == "" then
|
||||
result = ' '
|
||||
elseif result == nil then
|
||||
result = ''
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
@@ -179,7 +216,7 @@ require("lazy").setup({
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'filename' },
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = {},
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
@@ -187,16 +224,25 @@ require("lazy").setup({
|
||||
lualine_z = { 'progress', 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
lualine_c = {},
|
||||
-- lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_x = {},
|
||||
lualine_y = { 'filesize' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
winbar = {
|
||||
lualine_a = {
|
||||
{ breadcrumb,
|
||||
color = { bg = '#101010', fg = '#568200' },
|
||||
},
|
||||
},
|
||||
},
|
||||
inactive_winbar = {
|
||||
lualine_a = { breadcrumb },
|
||||
},
|
||||
extensions = {}
|
||||
}
|
||||
end
|
||||
@@ -245,9 +291,6 @@ require("lazy").setup({
|
||||
"PhilRunninger/cmp-rpncalc",
|
||||
},
|
||||
|
||||
-- comfortable table editing, esp. used in orgmode
|
||||
{ 'dhruvasagar/vim-table-mode' },
|
||||
|
||||
-- TODO, WARN, HACK, PERF, NOTE, TEST and others highlighting and searching
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
@@ -269,14 +312,131 @@ require("lazy").setup({
|
||||
"itchyny/calendar.vim"
|
||||
},
|
||||
|
||||
--------------------------------------------------
|
||||
--
|
||||
-- Color schemes
|
||||
--
|
||||
--------------------------------------------------
|
||||
-- treesitter asciidoc support
|
||||
{ "cpkio/nvim-treesitter-asciidoc" },
|
||||
|
||||
|
||||
-- Greeter to run on NeoVim startup
|
||||
{
|
||||
"rktjmp/lush.nvim"
|
||||
-- if you wish to use your own colorscheme:
|
||||
-- { dir = '/absolute/path/to/colorscheme', lazy = true },
|
||||
'goolord/alpha-nvim',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
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
|
||||
|
||||
-- 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 .. margin
|
||||
dashboard.section.header.val = vim.split(adjustedLogo, '\n')
|
||||
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button('n', ' New file', ':ene <BAR> startinsert <CR>'),
|
||||
dashboard.button('u', ' Update plugins', '<cmd>Lazy update<CR>'),
|
||||
dashboard.button('s', ' Settings', '<cmd>WorkspacesOpen config-nvim<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)
|
||||
end,
|
||||
},
|
||||
|
||||
-- improved Rust support
|
||||
{
|
||||
'mrcjkb/rustaceanvim',
|
||||
version = '^5', -- Recommended
|
||||
lazy = false, -- This plugin is already lazy
|
||||
},
|
||||
|
||||
-- show git changes on the left
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require('gitsigns').setup()
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user