mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-17 05:54:02 +00:00
chore(config): tweaks to nvim config, autogroups
This commit is contained in:
@@ -51,4 +51,21 @@ autocmd('FileType', {
|
|||||||
callback = function(event) vim.bo[event.buf].buflisted = false end,
|
callback = function(event) vim.bo[event.buf].buflisted = false end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- ── wrap and check for spell in text filetypes ──────────────────────
|
||||||
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
group = augroup('wrap_spell', { clear = true }),
|
||||||
|
pattern = { 'text', 'plaintex', 'typst', 'gitcommit', 'markdown' },
|
||||||
|
callback = function()
|
||||||
|
vim.opt_local.wrap = true
|
||||||
|
vim.opt_local.spell = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- ── Fix conceallevel for json files ─────────────────────────────────
|
||||||
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||||
|
group = augroup('json_conceal', { clear = true }),
|
||||||
|
pattern = { 'json', 'jsonc', 'json5' },
|
||||||
|
callback = function() vim.opt_local.conceallevel = 0 end,
|
||||||
|
})
|
||||||
|
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|||||||
@@ -1,49 +1,45 @@
|
|||||||
-- ── Formatting ──────────────────────────────────────────────────────
|
-- ── Formatting ──────────────────────────────────────────────────────
|
||||||
-- Lightweight yet powerful formatter plugin for Neovim
|
-- Lightweight yet powerful formatter plugin for Neovim
|
||||||
-- https://github.com/stevearc/conform.nvim
|
-- https://github.com/stevearc/conform.nvim
|
||||||
return {
|
|
||||||
'stevearc/conform.nvim',
|
|
||||||
event = { 'BufWritePre' },
|
|
||||||
cmd = { 'ConformInfo' },
|
|
||||||
config = function()
|
|
||||||
-- Select first conform formatter that is available
|
|
||||||
---@param bufnr integer
|
|
||||||
---@param ... string
|
|
||||||
---@return string
|
|
||||||
local function first(bufnr, ...)
|
|
||||||
local conform = require 'conform'
|
|
||||||
for i = 1, select('#', ...) do
|
|
||||||
local formatter = select(i, ...)
|
|
||||||
if conform.get_formatter_info(formatter, bufnr).available then
|
|
||||||
return formatter
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return select(1, ...)
|
|
||||||
end
|
|
||||||
|
|
||||||
require('conform').setup {
|
return {
|
||||||
|
{
|
||||||
|
'stevearc/conform.nvim',
|
||||||
|
event = { 'BufWritePre' },
|
||||||
|
cmd = { 'ConformInfo' },
|
||||||
|
opts = {
|
||||||
-- Enable or disable logging
|
-- Enable or disable logging
|
||||||
notify_on_error = true,
|
notify_on_error = false,
|
||||||
-- Set the default formatter for all filetypes
|
-- Set the default formatter for all filetypes
|
||||||
default_formatter = 'injected',
|
default_formatter = 'injected',
|
||||||
-- Set the default formatter for all filetypes
|
-- Set the default formatter for all filetypes
|
||||||
default_formatter_opts = {
|
default_formatter_opts = {
|
||||||
lsp_format = 'fallback',
|
lsp_format = 'fallback',
|
||||||
-- Set the default formatter for all filetypes
|
-- Set the default formatter for all filetypes
|
||||||
-- formatter = 'injected',
|
formatter = 'injected',
|
||||||
-- Set the default formatter for all filetypes
|
-- Set the default formatter for all filetypes
|
||||||
-- formatter_opts = {},
|
-- formatter_opts = {},
|
||||||
},
|
},
|
||||||
|
-- The options you set here will be merged with the builtin formatters.
|
||||||
|
-- You can also define any custom formatters here.
|
||||||
|
formatters = {
|
||||||
|
injected = { options = { ignore_errors = true } },
|
||||||
|
-- # Example of using dprint only when a dprint.json file is present
|
||||||
|
-- dprint = {
|
||||||
|
-- condition = function(ctx)
|
||||||
|
-- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1]
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
--
|
||||||
|
-- # Example of using shfmt with extra args
|
||||||
|
-- shfmt = {
|
||||||
|
-- prepend_args = { "-i", "2", "-ci" },
|
||||||
|
-- },
|
||||||
|
},
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
markdown = function(bufnr)
|
|
||||||
return { first(bufnr, 'prettierd', 'prettier'), 'injected' }
|
|
||||||
end,
|
|
||||||
javascript = function(bufnr)
|
|
||||||
return { first(bufnr, 'prettier', 'eslint'), 'injected' }
|
|
||||||
end,
|
|
||||||
lua = { 'stylua' },
|
lua = { 'stylua' },
|
||||||
-- Conform will run multiple formatters sequentially
|
-- Conform will run multiple formatters sequentially
|
||||||
-- python = { 'isort', 'black', lsp_format = 'fallback' },
|
go = { 'goimports', 'gofmt' },
|
||||||
-- You can customize some of the format options for the filetype (:help conform.format)
|
-- You can customize some of the format options for the filetype (:help conform.format)
|
||||||
-- rust = { 'rustfmt', lsp_format = 'fallback' },
|
-- rust = { 'rustfmt', lsp_format = 'fallback' },
|
||||||
},
|
},
|
||||||
@@ -59,9 +55,7 @@ return {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Disable with a global or buffer-local variable
|
-- Disable with a global or buffer-local variable
|
||||||
if
|
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||||
vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat
|
|
||||||
then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Disable autoformat for files in a certain path
|
-- Disable autoformat for files in a certain path
|
||||||
@@ -73,12 +67,20 @@ return {
|
|||||||
|
|
||||||
return { timeout_ms = 500, lsp_format = 'fallback' }
|
return { timeout_ms = 500, lsp_format = 'fallback' }
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
end,
|
init = function()
|
||||||
init = function()
|
-- If you want the formatexpr, here is the place to set it
|
||||||
-- If you want the formatexpr, here is the place to set it
|
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
end,
|
||||||
end,
|
},
|
||||||
|
-- Automatically install formatters registered with conform.nvim via mason.nvim
|
||||||
|
-- https://github.com/zapling/mason-conform.nvim
|
||||||
|
{
|
||||||
|
'zapling/mason-conform.nvim',
|
||||||
|
depends = {
|
||||||
|
'stevearc/conform.nvim',
|
||||||
|
'williamboman/mason.nvim',
|
||||||
|
},
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ return {
|
|||||||
config = function()
|
config = function()
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities.textDocument.foldingRange = {
|
capabilities.textDocument.foldingRange = {
|
||||||
dynamicRegistration = false,
|
dynamicRegistration = true,
|
||||||
lineFoldingOnly = true,
|
lineFoldingOnly = true,
|
||||||
}
|
}
|
||||||
local language_servers = require('lspconfig').util.available_servers() -- or list servers manually like {'gopls', 'clangd'}
|
local language_servers = require('lspconfig').util.available_servers() -- or list servers manually like {'gopls', 'clangd'}
|
||||||
@@ -84,7 +84,13 @@ return {
|
|||||||
---@param width number The width of the window.
|
---@param width number The width of the window.
|
||||||
---@param truncate function Truncate function
|
---@param truncate function Truncate function
|
||||||
---@return table
|
---@return table
|
||||||
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate)
|
fold_virt_text_handler = function(
|
||||||
|
virtText,
|
||||||
|
lnum,
|
||||||
|
endLnum,
|
||||||
|
width,
|
||||||
|
truncate
|
||||||
|
)
|
||||||
local newVirtText = {}
|
local newVirtText = {}
|
||||||
local suffix = (' %d '):format(endLnum - lnum)
|
local suffix = (' %d '):format(endLnum - lnum)
|
||||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Extensible Neovim Scrollbar
|
-- A neovim plugin that shows colorcolumn dynamically
|
||||||
-- https://github.com/petertriho/nvim-scrollbar
|
-- https://github.com/Bekaboo/deadcolumn.nvim
|
||||||
{ 'petertriho/nvim-scrollbar', opts = {} },
|
{ 'Bekaboo/deadcolumn.nvim' },
|
||||||
|
|
||||||
-- vim dashboard
|
-- vim dashboard
|
||||||
-- https://github.com/nvimdev/dashboard-nvim
|
-- https://github.com/nvimdev/dashboard-nvim
|
||||||
@@ -110,25 +110,60 @@ return {
|
|||||||
{
|
{
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
main = 'ibl',
|
main = 'ibl',
|
||||||
config = function()
|
opts = {
|
||||||
require('ibl').setup {
|
scope = { show_start = false, show_end = false },
|
||||||
indent = {
|
indent = {
|
||||||
char = '│',
|
char = '│',
|
||||||
|
tab_char = '│',
|
||||||
|
},
|
||||||
|
exclude = {
|
||||||
|
filetypes = {
|
||||||
|
'Trouble',
|
||||||
|
'alpha',
|
||||||
|
'dashboard',
|
||||||
|
'help',
|
||||||
|
'lazy',
|
||||||
|
'lazyterm',
|
||||||
|
'mason',
|
||||||
|
'neo-tree',
|
||||||
|
'notify',
|
||||||
|
'terminal',
|
||||||
|
'toggleterm',
|
||||||
|
'trouble',
|
||||||
},
|
},
|
||||||
exclude = {
|
buftypes = { 'dashboard' },
|
||||||
filetypes = { 'terminal', 'dashboard' },
|
},
|
||||||
buftypes = { 'dashboard' },
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
-- icons
|
||||||
|
{
|
||||||
|
'echasnovski/mini.icons',
|
||||||
|
opts = {
|
||||||
|
file = {
|
||||||
|
['.keep'] = { glyph = '', hl = 'MiniIconsGrey' },
|
||||||
|
['devcontainer.json'] = { glyph = '', hl = 'MiniIconsAzure' },
|
||||||
|
},
|
||||||
|
filetype = {
|
||||||
|
dotenv = { glyph = '', hl = 'MiniIconsYellow' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
package.preload['nvim-web-devicons'] = function()
|
||||||
|
require('mini.icons').mock_nvim_web_devicons()
|
||||||
|
return package.loaded['nvim-web-devicons']
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- ui components
|
||||||
|
{ 'MunifTanjim/nui.nvim', lazy = true },
|
||||||
|
|
||||||
-- Git integration for buffers
|
-- Git integration for buffers
|
||||||
-- https://github.com/lewis6991/gitsigns.nvim
|
-- https://github.com/lewis6991/gitsigns.nvim
|
||||||
{
|
{
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
version = false,
|
version = false,
|
||||||
lazy = false,
|
|
||||||
opts = {
|
opts = {
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = '+' },
|
add = { text = '+' },
|
||||||
@@ -174,6 +209,7 @@ return {
|
|||||||
'TmuxNavigateRight',
|
'TmuxNavigateRight',
|
||||||
'TmuxNavigatePrevious',
|
'TmuxNavigatePrevious',
|
||||||
},
|
},
|
||||||
|
opts = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Cloak allows you to overlay *'s over defined patterns in defined files.
|
-- Cloak allows you to overlay *'s over defined patterns in defined files.
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ return {
|
|||||||
{
|
{
|
||||||
'<leader>cf',
|
'<leader>cf',
|
||||||
'<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>',
|
'<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>',
|
||||||
mode = { 'n', 'v' },
|
mode = {},
|
||||||
desc = 'Format buffer',
|
desc = 'Format buffer with Conform',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'<leader>ci',
|
'<leader>ci',
|
||||||
@@ -509,7 +509,7 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- ── Old habits ──────────────────────────────────────────────────────
|
-- ── Old habits ──────────────────────────────────────────────────────
|
||||||
{ '<C-s>', '<cmd>w<CR>', desc = 'Save file' },
|
{ '<C-s>', '<cmd>w!<CR>', desc = 'Save file' },
|
||||||
|
|
||||||
-- ── Text manipulation in visual mode ────────────────────────────────
|
-- ── Text manipulation in visual mode ────────────────────────────────
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user