add formatters

pull/1704/head
T 5 months ago
parent c5e5964e56
commit 504543e148

@ -128,6 +128,8 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end,
})
-- ~/.local/share/nvim
-- This is the location that nvim installs all the plugins
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
@ -640,6 +642,8 @@ require('lazy').setup({
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
'clang-format', -- Need to install venv via `sudo apt install python3.12-venv`
'black',
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
@ -680,7 +684,8 @@ require('lazy').setup({
-- 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 }
-- local disable_filetypes = { c = true, cpp = true }
local disable_filetypes = {}
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
@ -692,12 +697,19 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
c = { 'clang-format' },
python = { 'black' },
-- 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 },
},
formatters = {
['clang-format'] = {
prepend_args = { '--style=file', '--fallback-style=LLVM' },
},
},
},
},

@ -0,0 +1,12 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 100
---
Language: C
PointerAlignment: Left
BreakBeforeBraces: Attach
AlignAfterOpenBracket: BlockIndent
Loading…
Cancel
Save