Compare commits

..

No commits in common. "2ea6bf6fea457f7a25a17e1c0c2232cc0106a3d2" and "77d74fac16931b1e33dba9a479bb5bb63571415a" have entirely different histories.

7 changed files with 33 additions and 77 deletions

7
.gitignore vendored
View File

@ -5,10 +5,9 @@ nvim
spell/ spell/
# In your personal fork, you likely want to comment this, since it's recommended to track # You likely want to comment this, since it's recommended to track lazy-lock.json in version
# lazy-lock.json in version control - see https://lazy.folke.io/usage/lockfile # control, see https://lazy.folke.io/usage/lockfile
# For the official `nvim-lua/kickstart.nvim` git repository, we leave it ignored to avoid unneeded # For kickstart, it makes sense to leave it ignored.
# merge conflicts.
lazy-lock.json lazy-lock.json
.DS_Store .DS_Store

View File

@ -8,7 +8,7 @@ return {
keys = { keys = {
{ {
'<leader>f', '<leader>f',
function() require('conform').format { async = true } end, function() require('conform').format { async = true, lsp_format = 'fallback' } end,
mode = '', mode = '',
desc = '[F]ormat buffer', desc = '[F]ormat buffer',
}, },
@ -18,23 +18,21 @@ return {
opts = { opts = {
notify_on_error = false, notify_on_error = false,
format_on_save = function(bufnr) format_on_save = function(bufnr)
-- You can specify filetypes to autoformat on save here: -- Disable "format_on_save lsp_fallback" for languages that don't
local enabled_filetypes = { -- have a well standardized coding style. You can add additional
-- lua = true, -- languages here or re-enable it for the disabled ones.
-- python = true, local disable_filetypes = { c = true, cpp = true }
} if disable_filetypes[vim.bo[bufnr].filetype] then
if enabled_filetypes[vim.bo[bufnr].filetype] then
return { timeout_ms = 500 }
else
return nil return nil
else
return {
timeout_ms = 500,
lsp_format = 'fallback',
}
end end
end, end,
default_format_opts = {
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
},
-- You can also specify external formatters in here.
formatters_by_ft = { formatters_by_ft = {
-- rust = { 'rustfmt' }, lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially -- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" }, -- python = { "isort", "black" },
-- --

View File

@ -63,20 +63,15 @@ return {
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
map('n', '<leader>hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' })
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
map('n', '<leader>hi', gitsigns.preview_hunk_inline, { desc = 'git preview hunk [i]nline' }) map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
map('n', '<leader>hb', function() gitsigns.blame_line { full = true } end, { desc = 'git [b]lame line' })
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
map('n', '<leader>hD', function() gitsigns.diffthis '@' end, { desc = 'git [D]iff against last commit' }) map('n', '<leader>hD', function() gitsigns.diffthis '@' end, { desc = 'git [D]iff against last commit' })
map('n', '<leader>hQ', function() gitsigns.setqflist 'all' end, { desc = 'git hunk [Q]uickfix list (all files in repo)' })
map('n', '<leader>hq', gitsigns.setqflist, { desc = 'git hunk [q]uickfix list (all changes in this file)' })
-- Toggles -- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
map('n', '<leader>tw', gitsigns.toggle_word_diff, { desc = '[T]oggle git intra-line [w]ord diff' }) map('n', '<leader>tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' })
-- Text object
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk)
end, end,
}, },
} }

View File

@ -8,7 +8,7 @@ return {
config = function() config = function()
local lint = require 'lint' local lint = require 'lint'
lint.linters_by_ft = { lint.linters_by_ft = {
markdown = { 'markdownlint' }, -- Make sure to install `markdownlint` via mason / npm markdown = { 'markdownlint' },
} }
-- To allow other plugins to add linters to require('lint').linters_by_ft, -- To allow other plugins to add linters to require('lint').linters_by_ft,

View File

@ -138,8 +138,6 @@ return {
-- Special Lua Config, as recommended by neovim help docs -- Special Lua Config, as recommended by neovim help docs
lua_ls = { lua_ls = {
on_init = function(client) on_init = function(client)
client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
if client.workspace_folders then if client.workspace_folders then
local path = client.workspace_folders[1].name local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
@ -161,11 +159,8 @@ return {
}, },
}) })
end, end,
---@type lspconfig.settings.lua_ls
settings = { settings = {
Lua = { Lua = {},
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
},
}, },
}, },
} }

View File

@ -8,16 +8,9 @@ return {
-- --
-- Examples: -- Examples:
-- - va) - [V]isually select [A]round [)]paren -- - va) - [V]isually select [A]round [)]paren
-- - yiiq - [Y]ank [I]nside [I]+1 [Q]uote -- - yinq - [Y]ank [I]nside [N]ext [Q]uote
-- - ci' - [C]hange [I]nside [']quote -- - ci' - [C]hange [I]nside [']quote
require('mini.ai').setup { require('mini.ai').setup { n_lines = 500 }
-- NOTE: Avoid conflicts with the built-in incremental selection mappings on Neovim>=0.12 (see `:help treesitter-incremental-selection`)
mappings = {
around_next = 'aa',
inside_next = 'ii',
},
n_lines = 500,
}
-- Add/delete/replace surroundings (brackets, quotes, etc.) -- Add/delete/replace surroundings (brackets, quotes, etc.)
-- --

View File

@ -8,32 +8,8 @@ return {
branch = 'main', branch = 'main',
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro` -- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
config = function() config = function()
-- ensure basic parser are installed
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
require('nvim-treesitter').install(parsers) require('nvim-treesitter').install(parsers)
---@param buf integer
---@param language string
local function treesitter_try_attach(buf, language)
-- check if parser exists and load it
if not vim.treesitter.language.add(language) then return end
-- enables syntax highlighting and other treesitter features
vim.treesitter.start(buf, language)
-- enables treesitter based folds
-- for more info on folds see `:help folds`
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
-- vim.wo.foldmethod = 'expr'
-- check if treesitter indentation is available for this language, and if so enable it
-- in case there is no indent query, the indentexpr will fallback to the vim's built in one
local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil
-- enables treesitter based indentation
if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end
end
local available_parsers = require('nvim-treesitter').get_available()
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
callback = function(args) callback = function(args)
local buf, filetype = args.buf, args.match local buf, filetype = args.buf, args.match
@ -41,18 +17,18 @@ return {
local language = vim.treesitter.language.get_lang(filetype) local language = vim.treesitter.language.get_lang(filetype)
if not language then return end if not language then return end
local installed_parsers = require('nvim-treesitter').get_installed 'parsers' -- check if parser exists and load it
if not vim.treesitter.language.add(language) then return end
-- enables syntax highlighting and other treesitter features
vim.treesitter.start(buf, language)
if vim.tbl_contains(installed_parsers, language) then -- enables treesitter based folds
-- enable the parser if it is installed -- for more info on folds see `:help folds`
treesitter_try_attach(buf, language) -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
elseif vim.tbl_contains(available_parsers, language) then -- vim.wo.foldmethod = 'expr'
-- if a parser is available in `nvim-treesitter` auto install it, and enable it after the installation is done
require('nvim-treesitter').install(language):await(function() treesitter_try_attach(buf, language) end) -- enables treesitter based indentation
else vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
treesitter_try_attach(buf, language)
end
end, end,
}) })
end, end,