Initial commit
This commit is contained in:
133
plugin/40_plugins.lua
Normal file
133
plugin/40_plugins.lua
Normal file
@@ -0,0 +1,133 @@
|
||||
-- ┌─────────────────────────┐
|
||||
-- │ 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',
|
||||
'vimdoc',
|
||||
'markdown',
|
||||
-- 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({
|
||||
-- -- For example, if `lua-language-server` is installed, use `'lua_ls'` entry
|
||||
'lua_ls',
|
||||
})
|
||||
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' } },
|
||||
})
|
||||
end)
|
||||
|
||||
-- Mason ======================================================================
|
||||
now_if_args(function()
|
||||
add('mason-org/mason.nvim')
|
||||
require('mason').setup()
|
||||
end)
|
||||
|
||||
-- Catppuccin =================================================================
|
||||
MiniDeps.now(function()
|
||||
add({ source = 'catpuccin/nvim', name = 'catppuccin' })
|
||||
require('catppuccin').setup({
|
||||
flavour = 'mocha',
|
||||
dim_inactive = {
|
||||
enabled = true
|
||||
}
|
||||
})
|
||||
vim.cmd('colorscheme catppuccin')
|
||||
end)
|
||||
|
||||
-- Neogit =====================================================================
|
||||
later(function ()
|
||||
add({
|
||||
source = 'NeogitOrg/neogit',
|
||||
depends = { 'nvim-lua/plenary.nvim' }
|
||||
})
|
||||
local neogit = require('neogit')
|
||||
neogit.setup()
|
||||
vim.keymap.set("n", "<leader>gg", neogit.open, { desc = "Open Neogit UI" })
|
||||
end)
|
||||
Reference in New Issue
Block a user