245 lines
7.4 KiB
Lua
245 lines
7.4 KiB
Lua
-- ┌─────────────────────────┐
|
|
-- │ Plugins outside of MINI │
|
|
-- └─────────────────────────┘
|
|
--
|
|
-- This file contains installation and configuration of plugins outside of MINI.
|
|
-- They significantly improve user experience in a way not yet possible with MINI.
|
|
-- These are mostly plugins that provide programming language specific behavior.
|
|
--
|
|
-- Use this file to install and configure other such plugins.
|
|
|
|
-- Make concise helpers for installing/adding plugins in two stages
|
|
local add, later = MiniDeps.add, MiniDeps.later
|
|
local now_if_args = _G.Config.now_if_args
|
|
|
|
-- Tree-sitter ================================================================
|
|
|
|
-- Tree-sitter is a tool for fast incremental parsing. It converts text into
|
|
-- a hierarchical structure (called tree) that can be used to implement advanced
|
|
-- and/or more precise actions: syntax highlighting, textobjects, indent, etc.
|
|
--
|
|
now_if_args(function()
|
|
add({
|
|
source = 'nvim-treesitter/nvim-treesitter',
|
|
-- Update tree-sitter parser after plugin is updated
|
|
hooks = { post_checkout = function() vim.cmd('TSUpdate') end },
|
|
})
|
|
add({
|
|
source = 'nvim-treesitter/nvim-treesitter-textobjects',
|
|
-- Use `main` branch since `master` branch is frozen, yet still default
|
|
-- It is needed for compatibility with 'nvim-treesitter' `main` branch
|
|
checkout = 'main',
|
|
})
|
|
|
|
-- Define languages which will have parsers installed and auto enabled
|
|
local languages = {
|
|
-- These are already pre-installed with Neovim. Used as an example.
|
|
'lua',
|
|
'html',
|
|
'css',
|
|
'markdown',
|
|
'yaml',
|
|
'toml',
|
|
'python',
|
|
'javascript',
|
|
'typst',
|
|
-- Add here more languages with which you want to use tree-sitter
|
|
-- To see available languages:
|
|
-- - Execute `:=require('nvim-treesitter').get_available()`
|
|
-- - Visit 'SUPPORTED_LANGUAGES.md' file at
|
|
-- https://github.com/nvim-treesitter/nvim-treesitter/blob/main
|
|
}
|
|
local isnt_installed = function(lang)
|
|
return #vim.api.nvim_get_runtime_file('parser/' .. lang .. '.*', false) == 0
|
|
end
|
|
local to_install = vim.tbl_filter(isnt_installed, languages)
|
|
if #to_install > 0 then require('nvim-treesitter').install(to_install) end
|
|
|
|
-- Enable tree-sitter after opening a file for a target language
|
|
local filetypes = {}
|
|
for _, lang in ipairs(languages) do
|
|
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
|
|
table.insert(filetypes, ft)
|
|
end
|
|
end
|
|
local ts_start = function(ev) vim.treesitter.start(ev.buf) end
|
|
_G.Config.new_autocmd('FileType', filetypes, ts_start, 'Start tree-sitter')
|
|
end)
|
|
|
|
-- Language servers ===========================================================
|
|
|
|
-- Language Server Protocol (LSP) is a set of conventions that power creation of
|
|
-- language specific tools. It requires two parts:
|
|
-- - Server - program that performs language specific computations.
|
|
-- - Client - program that asks server for computations and shows results.
|
|
--
|
|
-- Add it now if file (and not 'mini.starter') is shown after startup.
|
|
now_if_args(function()
|
|
add('neovim/nvim-lspconfig')
|
|
|
|
-- Use `:h vim.lsp.enable()` to automatically enable language server based on
|
|
-- the rules provided by 'nvim-lspconfig'.
|
|
-- Use `:h vim.lsp.config()` or 'after/lsp/' directory to configure servers.
|
|
-- Uncomment and tweak the following `vim.lsp.enable()` call to enable servers.
|
|
vim.lsp.enable({
|
|
'lua_ls',
|
|
'basedpyright',
|
|
'ruff',
|
|
'html',
|
|
'css',
|
|
'toml',
|
|
'marksman',
|
|
})
|
|
end)
|
|
|
|
-- Formatting =================================================================
|
|
|
|
-- Programs dedicated to text formatting (a.k.a. formatters) are very useful.
|
|
-- Neovim has built-in tools for text formatting (see `:h gq` and `:h 'formatprg'`).
|
|
-- They can be used to configure external programs, but it might become tedious.
|
|
--
|
|
-- The 'stevearc/conform.nvim' plugin is a good and maintained solution for easier
|
|
-- formatting setup.
|
|
later(function()
|
|
add('stevearc/conform.nvim')
|
|
|
|
-- See also:
|
|
-- - `:h Conform`
|
|
-- - `:h conform-options`
|
|
-- - `:h conform-formatters`
|
|
require('conform').setup({
|
|
-- Map of filetype to formatters
|
|
-- Make sure that necessary CLI tool is available
|
|
formatters_by_ft = {
|
|
lua = { 'stylua' },
|
|
python = { 'ruff' },
|
|
},
|
|
})
|
|
end)
|
|
|
|
-- Mason ======================================================================
|
|
now_if_args(function()
|
|
add('mason-org/mason.nvim')
|
|
require('mason').setup()
|
|
end)
|
|
|
|
-- Catppuccin =================================================================
|
|
now_if_args(function()
|
|
add({ source = 'catppuccin/nvim', name = 'catppuccin' })
|
|
require('catppuccin').setup({
|
|
flavour = 'mocha',
|
|
transparent_background = true,
|
|
dim_inactive = {
|
|
enabled = true,
|
|
},
|
|
float = {
|
|
transparent = true,
|
|
},
|
|
compile_path = vim.fn.stdpath "cache" .. "/catppuccin",
|
|
})
|
|
vim.cmd('colorscheme catppuccin')
|
|
end)
|
|
|
|
-- Neogit =====================================================================
|
|
later(function()
|
|
add({
|
|
source = 'NeogitOrg/neogit',
|
|
depends = { 'nvim-lua/plenary.nvim' },
|
|
})
|
|
require('neogit').setup()
|
|
end)
|
|
|
|
-- Gitsigns ===================================================================
|
|
later(function()
|
|
add({
|
|
source = 'lewis6991/gitsigns.nvim',
|
|
})
|
|
require('gitsigns').setup({})
|
|
end)
|
|
|
|
-- claudecode =================================================================
|
|
-- later(function ()
|
|
-- add({
|
|
-- source = 'coder/claudecode.nvim',
|
|
-- depends = { 'folke/snacks.nvim' },
|
|
-- })
|
|
-- require('claudecode').setup({})
|
|
-- end)
|
|
--
|
|
-- open code ==================================================================
|
|
later(function()
|
|
add({
|
|
source = 'nickjvandyke/opencode.nvim',
|
|
depends = { 'folke/snacks.nvim' },
|
|
})
|
|
|
|
vim.g.opencode_opts = {
|
|
provider = {
|
|
enabled = 'terminal',
|
|
terminal = {
|
|
width = math.floor(vim.o.columns * 0.5),
|
|
},
|
|
},
|
|
}
|
|
|
|
-- Handle `opencode` events
|
|
-- vim.api.nvim_create_autocmd('User', {
|
|
-- pattern = 'OpencodeEvent:*', -- Optionally filter event types
|
|
-- callback = function(args)
|
|
-- ---@type opencode.cli.client.Event
|
|
-- local event = args.data.event
|
|
-- ---@type number
|
|
-- local port = args.data.port
|
|
--
|
|
-- -- See the available event types and their properties
|
|
-- vim.notify(vim.inspect(event))
|
|
-- -- Do something useful
|
|
-- if event.type == 'session.idle' then
|
|
-- vim.notify('`opencode` finished responding')
|
|
-- end
|
|
-- end,
|
|
-- })
|
|
end)
|
|
|
|
-- zk =========================================================================
|
|
later(function()
|
|
add({
|
|
source = 'zk-org/zk-nvim',
|
|
})
|
|
require('zk').setup({
|
|
picker = 'minipick',
|
|
enabled = 'snacks',
|
|
lsp = {
|
|
config = {
|
|
name = 'zk',
|
|
cmd = { 'zk', 'lsp' },
|
|
filetypes = { 'markdown' },
|
|
},
|
|
},
|
|
auto_attach = {
|
|
enabled = true,
|
|
},
|
|
})
|
|
end)
|
|
|
|
-- checkmate ====================================================================
|
|
now_if_args(function()
|
|
add({
|
|
source = 'bngarren/checkmate.nvim',
|
|
})
|
|
require('checkmate').setup({
|
|
files = { '/home/mds/notes/TODO.md' },
|
|
})
|
|
end)
|
|
|
|
-- render-markdown.nvim ========================================================
|
|
now_if_args(function ()
|
|
add({
|
|
source = 'MeanderingProgrammer/render-markdown.nvim',
|
|
})
|
|
require('render-markdown').setup({
|
|
enabled = true,
|
|
file_types = {'markdown', 'vimwiki'},
|
|
})
|
|
end)
|