mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +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,
|
||||
})
|
||||
|
||||
-- ── 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
|
||||
|
||||
@@ -1,49 +1,45 @@
|
||||
-- ── Formatting ──────────────────────────────────────────────────────
|
||||
-- Lightweight yet powerful formatter plugin for Neovim
|
||||
-- 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
|
||||
notify_on_error = true,
|
||||
notify_on_error = false,
|
||||
-- Set the default formatter for all filetypes
|
||||
default_formatter = 'injected',
|
||||
-- Set the default formatter for all filetypes
|
||||
default_formatter_opts = {
|
||||
lsp_format = 'fallback',
|
||||
-- Set the default formatter for all filetypes
|
||||
-- formatter = 'injected',
|
||||
formatter = 'injected',
|
||||
-- Set the default formatter for all filetypes
|
||||
-- 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 = {
|
||||
markdown = function(bufnr)
|
||||
return { first(bufnr, 'prettierd', 'prettier'), 'injected' }
|
||||
end,
|
||||
javascript = function(bufnr)
|
||||
return { first(bufnr, 'prettier', 'eslint'), 'injected' }
|
||||
end,
|
||||
lua = { 'stylua' },
|
||||
-- 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)
|
||||
-- rust = { 'rustfmt', lsp_format = 'fallback' },
|
||||
},
|
||||
@@ -59,9 +55,7 @@ return {
|
||||
return
|
||||
end
|
||||
-- Disable with a global or buffer-local variable
|
||||
if
|
||||
vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat
|
||||
then
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
-- Disable autoformat for files in a certain path
|
||||
@@ -73,12 +67,20 @@ return {
|
||||
|
||||
return { timeout_ms = 500, lsp_format = 'fallback' }
|
||||
end,
|
||||
}
|
||||
end,
|
||||
init = function()
|
||||
-- If you want the formatexpr, here is the place to set it
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
end,
|
||||
|
||||
|
||||
},
|
||||
init = function()
|
||||
-- If you want the formatexpr, here is the place to set it
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
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()
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
dynamicRegistration = true,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
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 truncate function Truncate function
|
||||
---@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 suffix = (' %d '):format(endLnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
|
||||
@@ -27,9 +27,9 @@ return {
|
||||
},
|
||||
},
|
||||
|
||||
-- Extensible Neovim Scrollbar
|
||||
-- https://github.com/petertriho/nvim-scrollbar
|
||||
{ 'petertriho/nvim-scrollbar', opts = {} },
|
||||
-- A neovim plugin that shows colorcolumn dynamically
|
||||
-- https://github.com/Bekaboo/deadcolumn.nvim
|
||||
{ 'Bekaboo/deadcolumn.nvim' },
|
||||
|
||||
-- vim dashboard
|
||||
-- https://github.com/nvimdev/dashboard-nvim
|
||||
@@ -110,25 +110,60 @@ return {
|
||||
{
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
main = 'ibl',
|
||||
config = function()
|
||||
require('ibl').setup {
|
||||
indent = {
|
||||
char = '│',
|
||||
opts = {
|
||||
scope = { show_start = false, show_end = false },
|
||||
indent = {
|
||||
char = '│',
|
||||
tab_char = '│',
|
||||
},
|
||||
exclude = {
|
||||
filetypes = {
|
||||
'Trouble',
|
||||
'alpha',
|
||||
'dashboard',
|
||||
'help',
|
||||
'lazy',
|
||||
'lazyterm',
|
||||
'mason',
|
||||
'neo-tree',
|
||||
'notify',
|
||||
'terminal',
|
||||
'toggleterm',
|
||||
'trouble',
|
||||
},
|
||||
exclude = {
|
||||
filetypes = { 'terminal', 'dashboard' },
|
||||
buftypes = { '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,
|
||||
},
|
||||
|
||||
-- ui components
|
||||
{ 'MunifTanjim/nui.nvim', lazy = true },
|
||||
|
||||
-- Git integration for buffers
|
||||
-- https://github.com/lewis6991/gitsigns.nvim
|
||||
{
|
||||
'lewis6991/gitsigns.nvim',
|
||||
version = false,
|
||||
lazy = false,
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
@@ -174,6 +209,7 @@ return {
|
||||
'TmuxNavigateRight',
|
||||
'TmuxNavigatePrevious',
|
||||
},
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- Cloak allows you to overlay *'s over defined patterns in defined files.
|
||||
|
||||
@@ -141,8 +141,8 @@ return {
|
||||
{
|
||||
'<leader>cf',
|
||||
'<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>',
|
||||
mode = { 'n', 'v' },
|
||||
desc = 'Format buffer',
|
||||
mode = {},
|
||||
desc = 'Format buffer with Conform',
|
||||
},
|
||||
{
|
||||
'<leader>ci',
|
||||
@@ -509,7 +509,7 @@ return {
|
||||
},
|
||||
|
||||
-- ── Old habits ──────────────────────────────────────────────────────
|
||||
{ '<C-s>', '<cmd>w<CR>', desc = 'Save file' },
|
||||
{ '<C-s>', '<cmd>w!<CR>', desc = 'Save file' },
|
||||
|
||||
-- ── Text manipulation in visual mode ────────────────────────────────
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user