commit e5bda7c8145599974e1120ebcba1f67afaedd634
parent 2ac255def48b4634827d454feb075e8ddf010b79
Author: Alex Balgavy <alexander.balgavy@spaceapplications.com>
Date: Fri, 6 Sep 2024 14:03:22 +0200
nvim: a bunch of settings
Diffstat:
5 files changed, 166 insertions(+), 93 deletions(-)
diff --git a/nvim/init.lua b/nvim/init.lua
@@ -5,13 +5,9 @@ call setenv("MYOLDVIMRC", "~/.vim/vimrc")
source $MYOLDVIMRC
]])
-if vim.lsp.buf.inlay_hint then
- vim.api.nvim_err_writeln("init.lua: inlay hints now available!")
-end
-
-- Install Lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
-if not vim.loop.fs_stat(lazypath) then
+if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
@@ -58,10 +54,10 @@ vim.api.nvim_create_autocmd('TextYankPost', {
-- Diagnostic keymaps
-vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
-vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
-vim.keymap.set('n', ']e', function() vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR }) end)
-vim.keymap.set('n', '[e', function() vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR }) end)
+vim.keymap.set('n', '[d', function() vim.diagnostic.jump({ count = -1, float = true }) end)
+vim.keymap.set('n', ']d', function() vim.diagnostic.jump({ count = 1, float = true }) end)
+vim.keymap.set('n', ']e', function() vim.diagnostic.jump({ count = 1, float = true, severity = vim.diagnostic.severity.ERROR }) end)
+vim.keymap.set('n', '[e', function() vim.diagnostic.jump({ count = -1, float = true, severity = vim.diagnostic.severity.ERROR }) end)
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>q', function() vim.diagnostic.setloclist({ severity = vim.diagnostic.severity.ERROR }) end)
@@ -85,8 +81,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
- vim.notify("Nvim now has support for inlay hints")
- -- vim.lsp.inlay_hint.enable(ev.buf, true)
+ vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf })
end
end,
})
diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json
@@ -1,42 +1,43 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
- "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" },
- "aerial.nvim": { "branch": "master", "commit": "eb25396dae306cef5b8fffbe9ae98283d2f1c199" },
- "cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" },
+ "LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" },
+ "aerial.nvim": { "branch": "master", "commit": "b59e01e4380932b375ecff165b48a9400c4af929" },
+ "baleia.nvim": { "branch": "main", "commit": "880e97c02edf3148ba2bdc6305ac03eb3c3711e0" },
+ "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
- "diagflow.nvim": { "branch": "main", "commit": "4a03e94e1bf6d18feaac44476cfcb78b403bd609" },
- "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" },
- "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" },
- "flash.nvim": { "branch": "main", "commit": "43f67935d388fbb540f8b40e8cbfd80de54f978a" },
+ "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" },
+ "diagflow.nvim": { "branch": "main", "commit": "fc09d55d2e60edc8ed8f9939ba97b7b7e6488c99" },
+ "dressing.nvim": { "branch": "master", "commit": "c5775a888adbc50652cb370073fcfec963eca93e" },
+ "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
+ "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"formatter.nvim": { "branch": "master", "commit": "ad246d34ce7a32f752071ed81b09b94e6b127fad" },
- "gitsigns.nvim": { "branch": "main", "commit": "8df63f2ddc615feb71fd4aee45a4cee022876df1" },
- "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" },
- "lazy.nvim": { "branch": "main", "commit": "bc620783663ab09d16bff9fdecc07da65b2a1528" },
- "lsp-inlayhints.nvim": { "branch": "main", "commit": "d981f65c9ae0b6062176f0accb9c151daeda6f16" },
+ "gitsigns.nvim": { "branch": "main", "commit": "899e993850084ea33d001ec229d237bc020c19ae" },
+ "indent-blankline.nvim": { "branch": "master", "commit": "db926997af951da38e5004ec7b9fbdc480b48f5d" },
+ "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" },
"lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" },
- "mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
- "mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" },
- "mini.align": { "branch": "main", "commit": "68a8d3205f0e7ce1bded057f4a851f42ef8fc584" },
- "neodev.nvim": { "branch": "main", "commit": "02893eeb9d6e8503817bd52385e111cba9a90500" },
+ "markview.nvim": { "branch": "main", "commit": "ea71a5bc6e0a0b28af62e2f21d264ddcc466bd51" },
+ "mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" },
+ "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
+ "mini.align": { "branch": "main", "commit": "b54d88b16bfac62ca6b3d699566135639a3ca4fa" },
+ "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
- "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
+ "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-cmp-lsp-rs": { "branch": "main", "commit": "d9ebeca9ea07ba2fd57f997b2d6a8bc7da51abed" },
- "nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" },
- "nvim-dap-python": { "branch": "master", "commit": "ae0225d0d4a46e18e6057ab3701ef87bbbd6aaad" },
- "nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" },
- "nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" },
- "nvim-lspconfig": { "branch": "master", "commit": "9baca6a403b3b2098224010fda6ff5615ae6e782" },
- "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
- "nvim-treesitter": { "branch": "master", "commit": "122b4d3db1616c1f1305b847c5ed2217c4c329f1" },
- "nvim-treesitter-context": { "branch": "master", "commit": "5efba33af0f39942e426340da7bc15d7dec16474" },
- "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
- "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
- "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
- "precognition.nvim": { "branch": "main", "commit": "02dcc8f8db677fe02d2dd68da6155177283fe711" },
- "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
- "telescope-undo.nvim": { "branch": "main", "commit": "95b61c01ea3a4c9e8747731148e905bbcf0ccaee" },
- "telescope.nvim": { "branch": "master", "commit": "f2bfde705ac752c52544d5cfa8b0aee0a766c1ed" },
+ "nvim-dap": { "branch": "master", "commit": "281a2e4cd1e7a17cea7ecb1745d84a8ab1249925" },
+ "nvim-dap-python": { "branch": "master", "commit": "7c427e2bbc72d46ea3c9602bede6465ef61b8c19" },
+ "nvim-dap-ui": { "branch": "master", "commit": "1c351e4e417d4691da12948b6ecf966936a56d28" },
+ "nvim-dap-virtual-text": { "branch": "master", "commit": "484995d573c0f0563f6a66ebdd6c67b649489615" },
+ "nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" },
+ "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
+ "nvim-treesitter": { "branch": "master", "commit": "a1573a9135c608e68cb383f752623527be84bdce" },
+ "nvim-treesitter-context": { "branch": "master", "commit": "0ec9a8e00cedfb52e3c2259b55f46a7c18fc2429" },
+ "nvim-treesitter-textobjects": { "branch": "master", "commit": "3a3c6244553f13fdd92d312c82722b57ce6c4bec" },
+ "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
+ "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
+ "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
+ "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" },
+ "telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" },
"trouble.nvim": { "branch": "dev", "commit": "8a0394ce7c38d961b355160dfc1e4ab77b9a38d7" },
- "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }
-}-
\ No newline at end of file
+ "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }
+}
diff --git a/nvim/lua/config/mason-lspconfig.lua b/nvim/lua/config/mason-lspconfig.lua
@@ -66,15 +66,18 @@ local servers = {
"-A", "clippy::pub_use",
"-A", "clippy::single_char_lifetime_names",
"-A", "clippy::missing_trait_methods",
- "-A", "clippy::multiple_unsafe_ops_per_block", -- broken on 0.1.74
+ "-A", "clippy::multiple_unsafe_ops_per_block", -- broken on 0.1.74
"-A", "clippy::mod_module_files",
"-A", "clippy::std_instead_of_alloc",
"-A", "clippy::integer_division_remainder_used",
"-D", "rust_2018_idioms",
"-D", "missing_docs",
"-D", "warnings",
- "-A", "clippy::too_many_lines"},
- -- command = "check" },
+ "-A", "clippy::too_many_lines"
+ },
+ --[[
+ command = "check",
+ ]]
-- extraArgs = { "--no-deps" },
},
procMacro = {
@@ -88,13 +91,13 @@ local servers = {
},
},
pyright = {},
- -- solargraph = {},
- -- bashls = {},
- -- jdtls = {},
- -- jsonls = {},
- -- texlab = {},
- -- clangd = {},
- -- perlnavigator = {},
+ -- solargraph = {},
+ -- bashls = {},
+ -- jdtls = {},
+ -- jsonls = {},
+ -- texlab = {},
+ -- clangd = {},
+ -- perlnavigator = {},
}
@@ -121,6 +124,7 @@ local on_attach = function(_, bufnr)
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ra', vim.lsp.buf.code_action, '[C]ode [A]ction')
+ vim.keymap.set('v', '<leader>ra', vim.lsp.buf.code_action, { buffer = bufnr, desc = '[C]ode [A]ction' })
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
diff --git a/nvim/lua/config/telescope.lua b/nvim/lua/config/telescope.lua
@@ -9,10 +9,16 @@ require('telescope').setup {
},
},
}
+-- Disable folding in Telescope's result window.
+vim.api.nvim_create_autocmd("FileType",
+ { pattern = "TelescopeResults", command = [[setlocal nofoldenable foldlevelstart=99]] })
+
vim.keymap.set('n', '<leader>sp', require('telescope.builtin').oldfiles, { desc = '[S]earch [p]reviously opened files' })
vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = 'Find existing buffers' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
-vim.keymap.set('n', '<leader>cv', function() require('telescope.builtin').find_files({ cwd = vim.env.DOTFILES..'/nvim' }) end, { desc = 'Neovim configs' })
+vim.keymap.set('n', '<leader>cv',
+ function() require('telescope.builtin').find_files({ cwd = vim.env.DOTFILES .. '/nvim' }) end,
+ { desc = 'Neovim configs' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
@@ -20,7 +26,8 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').lsp_references, { desc = '[S]earch [R]eferences' })
vim.keymap.set('n', '<leader>s<', require('telescope.builtin').lsp_incoming_calls, { desc = '[S]earch [I]ncoming calls' })
vim.keymap.set('n', '<leader>s>', require('telescope.builtin').lsp_outgoing_calls, { desc = '[S]earch [O]utgoing calls' })
-vim.keymap.set('n', '<leader>sI', require('telescope.builtin').lsp_implementations, { desc = '[S]earch [i]mplementations' })
+vim.keymap.set('n', '<leader>sI', require('telescope.builtin').lsp_implementations,
+ { desc = '[S]earch [i]mplementations' })
vim.keymap.set('n', '<leader>ss', function()
local server_ready = not not vim.lsp.buf_notify(0, '$/progress', {})
if server_ready then
diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua
@@ -7,17 +7,20 @@ return {
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
- {'williamboman/mason.nvim',
+ {
+ 'williamboman/mason.nvim',
opts = {},
},
- { 'williamboman/mason-lspconfig.nvim',
+ {
+ 'williamboman/mason-lspconfig.nvim',
config = function()
require 'config.mason-lspconfig'
end,
},
-- Useful status updates for LSP
- {'j-hui/fidget.nvim',
+ {
+ 'j-hui/fidget.nvim',
opts = {},
},
@@ -96,11 +99,12 @@ return {
changedelete = { text = '~' },
},
on_attach = function()
- vim.keymap.set('n', ']c', function() require('gitsigns').next_hunk() end, {buffer = true})
- vim.keymap.set('n', '[c', function() require('gitsigns').prev_hunk() end, {buffer = true})
- vim.keymap.set('n', ']=', function() require('gitsigns').preview_hunk_inline() end, {buffer = true})
- vim.keymap.set('n', ']-', function() require('gitsigns').preview_hunk() end, {buffer = true})
- vim.keymap.set('n', ']+', function() require('gitsigns').select_hunk() end, {buffer = true})
+ vim.keymap.set('n', ']c', function() require('gitsigns').next_hunk() end, { buffer = true })
+ vim.keymap.set('n', '[c', function() require('gitsigns').prev_hunk() end, { buffer = true })
+ vim.keymap.set('n', ']=', function() require('gitsigns').toggle_deleted() end, { buffer = true })
+ vim.keymap.set('n', ']~', function() require('gitsigns').diffthis() end, { buffer = true })
+ vim.keymap.set('n', ']-', function() require('gitsigns').preview_hunk() end, { buffer = true })
+ vim.keymap.set('n', ']+', function() require('gitsigns').select_hunk() end, { buffer = true })
end,
},
},
@@ -122,7 +126,8 @@ return {
},
-- Fuzzy Finder (files, lsp, etc)
- { 'nvim-telescope/telescope.nvim',
+ {
+ 'nvim-telescope/telescope.nvim',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
require 'config.telescope'
@@ -130,7 +135,8 @@ return {
},
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available
- { 'nvim-telescope/telescope-fzf-native.nvim',
+ {
+ 'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = vim.fn.executable 'make' == 1
},
@@ -195,44 +201,57 @@ return {
},
-- DAP: debugging
- { 'mfussenegger/nvim-dap', config = function()
- require 'config.nvim-dap'
- end
+ {
+ 'mfussenegger/nvim-dap',
+ config = function()
+ require 'config.nvim-dap'
+ end
},
- {'mfussenegger/nvim-dap-python',
+ {
+ 'mfussenegger/nvim-dap-python',
config = function()
require('dap-python').setup(vim.fn.stdpath("data") .. "/mason/packages/debugpy/venv/bin/python")
end
},
- { "rcarriga/nvim-dap-ui", dependencies = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"}, config = function()
+ {
+ "rcarriga/nvim-dap-ui",
+ dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
+ config = function()
require 'config.nvim-dap-ui'
- end
+ end
},
- {'theHamsta/nvim-dap-virtual-text', dependencies = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"}, config = function()
- require("nvim-dap-virtual-text").setup()
- end},
+ {
+ 'theHamsta/nvim-dap-virtual-text',
+ dependencies = { "mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter" },
+ config = function()
+ require("nvim-dap-virtual-text").setup()
+ end
+ },
- { 'Eandrju/cellular-automaton.nvim', config = function()
- vim.keymap.set('n', 'q:', '<cmd>CellularAutomaton make_it_rain<CR>')
- end},
+ {
+ 'Eandrju/cellular-automaton.nvim',
+ config = function()
+ vim.keymap.set('n', 'q:', '<cmd>CellularAutomaton make_it_rain<CR>')
+ end
+ },
{
"folke/flash.nvim",
event = "VeryLazy",
---@type Flash.Config
opts = {
- search = {
+ search = {
trigger = "\\",
}
},
-- stylua: ignore
keys = {
- { "<leader><leader>s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
- { "<leader>S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
- { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
- { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
- { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
+ { "<leader><leader>s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
+ { "<leader>S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
+ { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
+ { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
+ { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
},
},
@@ -249,7 +268,7 @@ return {
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
opts = {},
- config = function(_, opts) require'lsp_signature'.setup(opts) end
+ config = function(_, opts) require 'lsp_signature'.setup(opts) end
},
-- LSP diagnostics at your corner.
@@ -276,12 +295,12 @@ return {
},
keys = {
{ "<leader>tt", "<cmd>AerialToggle!<cr>", desc = "Toggle tagbar" },
- { "<leader>to", "<cmd>AerialOpen<cr>", desc = "Open and jump to tagbar" },
+ { "<leader>to", "<cmd>AerialOpen<cr>", desc = "Open and jump to tagbar" },
},
},
{
"nvim-treesitter/nvim-treesitter-context",
- dependencies = {"nvim-treesitter/nvim-treesitter"},
+ dependencies = { "nvim-treesitter/nvim-treesitter" },
config = function()
require("treesitter-context").setup()
end
@@ -327,13 +346,17 @@ return {
},
{
"echasnovski/mini.align",
- config = function(_, opts) require'mini.align'.setup() end,
+ opts = {
+ mappings = {
+ start_with_preview = 'ga',
+ },
+ },
},
{
"m00qek/baleia.nvim",
version = "*",
config = function()
- vim.g.baleia = require("baleia").setup({ })
+ vim.g.baleia = require("baleia").setup({})
-- Command to colorize the current buffer
vim.api.nvim_create_user_command("BaleiaColorize", function()
@@ -346,11 +369,55 @@ return {
},
{
"OXY2DEV/markview.nvim",
- lazy = false, -- Not needed, already handled by plugin
+ lazy = false, -- Not needed, already handled by plugin
dependencies = {
- "nvim-treesitter/nvim-treesitter",
- "nvim-tree/nvim-web-devicons"
+ "nvim-treesitter/nvim-treesitter",
+ "nvim-tree/nvim-web-devicons"
}
},
+ { -- Autoformat
+ 'stevearc/conform.nvim',
+ event = { 'BufWritePre' },
+ cmd = { 'ConformInfo' },
+ keys = {
+ {
+ 'gQ',
+ function()
+ require('conform').format { async = true, lsp_fallback = true }
+ end,
+ mode = '',
+ desc = '[F]ormat buffer',
+ },
+ },
+ opts = {
+ notify_on_error = false,
+ format_on_save = function(bufnr)
+ -- Disable "format_on_save lsp_fallback" for languages that don't
+ -- have a well standardized coding style. You can add additional
+ -- languages here or re-enable it for the disabled ones.
+ local disable_filetypes = { c = true, cpp = true }
+ return {
+ timeout_ms = 500,
+ lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
+ }
+ end,
+ formatters = {
+ ruff = {
+ prepend_args = { "--config", "~/Documents/cdmi/automation/meta-files/ruff.toml" },
+ },
+ },
+ formatters_by_ft = {
+ rust = { "rustfmt", lsp_format = "fallback" },
+ python = { "ruff", lsp_format = "fallback" },
+ -- python = { "black", lsp_format = "fallback" },
+ -- -- lua = { 'stylua' },
+ -- -- Conform can also run multiple formatters sequentially
+ -- -- python = { "isort", "black" },
+ -- --
+ -- -- You can use 'stop_after_first' to run the first available formatter from the list
+ -- -- javascript = { "prettierd", "prettier", stop_after_first = true },
+ },
+ },
+ },
}