Files
neovim-configuration/lua/plugins.lua
Sascha Lüdecke 294870a25b Live coding with tidal and sonic pi, snippets for diary, toggleterm
Live Coding:

- added plugin for sonic-pi (though commented out)
- added plugin for tidal

Snippets:

- added path luasnippets to loaderdefinitions
- added luasnippet for asciidoc (diaentry, diahead

Options:

- no longer show tabline

Plugins:

- toggleterm with a binding so <C-`>
2024-10-28 13:24:14 +01:00

504 lines
14 KiB
Lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- Auto-completion engine
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
"hrsh7th/cmp-buffer", -- buffer auto-completion
"hrsh7th/cmp-path", -- path auto-completion
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
"saadparwaiz1/cmp_luasnip", -- luasnip auto-completion
},
config = function()
require("config.nvim-cmp")
end,
},
-- Code snippet engine
{
"L3MON4D3/LuaSnip",
version = "v2.*",
config = function()
require("luasnip.loaders.from_snipmate").lazy_load()
require("luasnip.loaders.from_lua").lazy_load()
end,
},
--
-- LSP manager and others
--
"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 = {
bind = true,
floating_window = false,
},
},
-- neogit setup
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"sindrets/diffview.nvim", -- optional - Diff integration
-- Only one of these is needed, not both.
-- "nvim-telescope/telescope.nvim", -- optional
"ibhagwan/fzf-lua", -- optional
},
config = true
},
-- org-mode
{
'nvim-orgmode/orgmode',
event = 'VeryLazy',
ft = { 'org' },
config = function()
-- Setup orgmode
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
-- add ~org~ to ignore_install
-- require('nvim-treesitter.configs').setup({
-- ensure_installed = 'all',
-- ignore_install = { 'org' },
-- })
end,
},
-- comfortable table editing, esp. used in orgmode
{ 'dhruvasagar/vim-table-mode' },
-- fzf-lua
{
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- calling `setup` is optional for customization
local fzf = require("fzf-lua")
fzf.setup({ "default-title" })
fzf.register_ui_select()
end
},
-- which-key
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
preset = 'helix',
expand = 4,
keys = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
plugins = {
presets = {
motions = true,
g = true,
}
},
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = true })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
dependencies = { "echasnovski/mini.icons" },
},
-- treesitter
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html", "diff", "go", "rust", "python" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})
end
},
-- lualine statusline plugin
{
'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,
theme = 'papercolor_light',
component_separators = {},
section_separators = {},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {},
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'filesize' },
lualine_z = { 'progress', 'location' }
},
inactive_sections = {
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
lualine_b = {},
lualine_c = {},
-- lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_x = {},
lualine_y = { 'filesize' },
lualine_z = { 'location' }
},
tabline = {},
winbar = {
lualine_a = {
{
breadcrumb,
color = { bg = '#2a2a2a', fg = '#cfcfcf' },
},
},
},
inactive_winbar = {
lualine_a = {
{ breadcrumb,
color = { bg = '#101010', fg = '#999999' },
draw_empty = true
}
},
},
extensions = {}
}
end
},
-- neo-tree file management
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
},
-- workspaces, lightweight "projects"
{
"natecraddock/workspaces.nvim",
config = function()
require("workspaces").setup {
-- sort the list of workspaces by name after loading from the workspaces path.
sort = true,
-- sort by recent use rather than by name. requires sort to be true
mru_sort = false,
-- option to automatically activate workspace when opening neovim in a workspace directory
auto_open = true,
-- option to automatically activate workspace when changing directory not via this plugin
auto_dir = true,
hooks = {
open = "FzfLua files"
}
}
end
},
-- rpn calculator
-- also added as source to cmp
{
"PhilRunninger/cmp-rpncalc",
},
-- TODO, WARN, HACK, PERF, NOTE, TEST and others highlighting and searching
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
},
-- highlight word under cursor
{
"dwrdx/mywords.nvim",
},
-- Calendar view
{
"itchyny/calendar.vim"
},
-- treesitter asciidoc support
{ "cpkio/nvim-treesitter-asciidoc" },
-- Greeter to run on NeoVim startup
{
'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,
},
-- -- Live Coding: sonic-pi music programming
-- {
-- 'magicmonty/sonicpi.nvim',
-- -- broken if used here, setup called further below
-- -- config = function()
-- -- require('sonicpi').setup()
-- -- end,
-- dependencies = {
-- 'hrsh7th/nvim-cmp',
-- 'kyazdani42/nvim-web-devicons'
-- },
-- },
-- easy term on a shortcut
{
"akinsho/toggleterm.nvim",
config = true,
keys = {
{
"<C-`>",
":ToggleTerm<CR>",
desc = "Toggle terminal",
},
{
"<C-`>",
"<C-\\><C-n>:ToggleTerm<CR>",
mode = 't',
desc = "Toggle terminal",
},
},
},
-- Live Coding: tidal cycles support
{
'tidalcycles/vim-tidal',
config = function()
vim.g.tidal_sc_enable = 1
end,
},
})
-- require('sonicpi').setup({
-- server_dir = '/opt/sonic-pi/app/server',
-- mappings = {
-- { 'n', '<leader>d', ':SonicPiStartDaemon<CR>', { desc = 'Sonic Pi: start daemon' } },
-- { 'n', '<leader>s', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
-- { 'i', '<M-s>', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
-- { 'n', '<leader>r', require('sonicpi.remote').run_current_buffer, { desc = 'Sonic Pi: run' } },
-- { 'i', '<M-r>', require('sonicpi.remote').run_current_buffer, { desc = 'Sonic Pi: run' } },
-- { 'n', '<leader>R', ':SonicPiSendBuffer<CR>', { desc = 'Sonic Pi: send buffer' } },
-- { 'i', '<M-R>', ':SonicPiSendBuffer<CR>', { desc = 'Sonic Pi: send buffer' } },
-- },
-- single_file = true,
-- })