Skip to content

Commit

Permalink
feat(plug): stevearc/conform.nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
willruggiano committed Jan 25, 2024
1 parent 48ba221 commit d8ba5e2
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 225 deletions.
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
git commit -am "bump: $1"
}
'';
plug-add.exec = ''
niv add git git@github.com:$1 && git add nix/ && git commit -am "feat(plug): $1"
'';
};
};

Expand Down
6 changes: 6 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
"rev": "6857f10272c3cfe930cece2afa2406e1385bfef8",
"type": "git"
},
"conform.nvim": {
"branch": "master",
"repo": "git@github.com:stevearc/conform.nvim",
"rev": "d99b75b4aedf0e912f41c5740a7267de739cddac",
"type": "git"
},
"cpsm": {
"branch": "master",
"repo": "git@github.com:nixprime/cpsm",
Expand Down
23 changes: 0 additions & 23 deletions plugins/bombadil/lua/bombadil/lsp/null-ls/alejandra.lua

This file was deleted.

17 changes: 0 additions & 17 deletions plugins/bombadil/lua/bombadil/lsp/null-ls/init.lua

This file was deleted.

24 changes: 0 additions & 24 deletions plugins/bombadil/lua/bombadil/lsp/null-ls/jsonnet.lua

This file was deleted.

34 changes: 0 additions & 34 deletions plugins/bombadil/lua/bombadil/lsp/null-ls/man.lua

This file was deleted.

23 changes: 0 additions & 23 deletions plugins/bombadil/lua/bombadil/lsp/null-ls/prisma.lua

This file was deleted.

77 changes: 0 additions & 77 deletions plugins/bombadil/lua/bombadil/lsp/null-ls/statix.lua

This file was deleted.

32 changes: 32 additions & 0 deletions plugins/conform.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
return function()
local js = { { "biome", "prettier" } }
local sh = { "shfmt", "shellcheck", "shellharden" }

require("conform").setup {
formatters_by_ft = {
bash = sh,
javascript = js,
javascriptreact = js,
lua = { "stylua", "luacheck" },
markdown = { "prettier", "injected" },
sh = sh,
sql = { "sqlfluff" },
typescript = js,
typescriptreact = js,
yaml = { "prettier" },
},
formatters = {
biome = {
command = "biome", -- not necessarily from node_modules/.bin
},
sqlfluff = {
prepend_args = { "--dialect", "postgres" },
},
stylua = {
require_cwd = true, -- only when it finds the root marker
},
},
}

vim.o.formatexpr = [[v:lua.require("conform").formatexpr()]]
end
32 changes: 14 additions & 18 deletions plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ return function()

local lsp_codelens = vim.api.nvim_create_augroup("LspCodelens", {})

local function format()
vim.lsp.buf.format {
async = true,
filter = function(client)
return client.name ~= "tsserver"
end,
}
end

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
Expand All @@ -95,7 +86,13 @@ return function()
{ buffer = bufnr, desc = "Code lens" },
},
["<leader>f"] = {
format,
function()
require("conform").format {
async = true,
bufnr = bufnr,
lsp_fallback = true,
}
end,
{ buffer = bufnr, desc = "Format" },
},
["<leader><leader>l"] = {
Expand Down Expand Up @@ -175,7 +172,13 @@ return function()
-- { buffer = bufnr, desc = "Code actions" },
-- },
["<leader>f"] = {
format,
function()
require("conform").format {
async = true,
bufnr = bufnr,
lsp_fallback = true,
}
end,
{ buffer = bufnr, desc = "Format" },
},
}
Expand Down Expand Up @@ -451,12 +454,10 @@ return function()

-- TODO: Move to separate file
local null_ls = require "null-ls"
local custom_sources = require "bombadil.lsp.null-ls"
null_ls.setup {
-- debug = true,
on_attach = on_attach,
sources = {
custom_sources.formatting.jsonnet,
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.code_actions.shellcheck.with { filetypes = { "bash", "sh" } },
null_ls.builtins.code_actions.statix,
Expand All @@ -466,11 +467,6 @@ return function()
null_ls.builtins.diagnostics.shellcheck.with { filetypes = { "bash", "sh" } },
null_ls.builtins.diagnostics.sqlfluff.with { extra_args = { "--dialect", "postgres" } },
null_ls.builtins.diagnostics.statix,
null_ls.builtins.formatting.shellharden.with { filetypes = { "bash", "sh" } },
null_ls.builtins.formatting.shfmt.with { filetypes = { "bash", "sh" } },
null_ls.builtins.formatting.sqlfluff.with { extra_args = { "--dialect", "postgres" } },
null_ls.builtins.formatting.stylua,
null_ls.builtins.hover.dictionary,
},
}

Expand Down
24 changes: 15 additions & 9 deletions plugins/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ in rec {
};
};

conform = {
src = sources."conform.nvim";
config = ./conform.lua;
paths = with pkgs; [
nodePackages.prettier # for markdown
shellcheck
shellharden
shfmt
sqlfluff
stylua
];
};

dap = {
src = sources.nvim-dap;
config = ./dap.lua;
Expand Down Expand Up @@ -262,7 +275,7 @@ in rec {
src = sources.nvim-lspconfig;
config = ./lsp.lua;
dependencies = {
inherit fun lspkind sg;
inherit conform fun lspkind sg;
clangd_extensions = {
src = sources."clangd_extensions.nvim";
};
Expand All @@ -287,23 +300,16 @@ in rec {
};
};
paths = with pkgs; [
(pkgs.callPackage ../pkgs/languagetool-rs {})
# (pkgs.callPackage ../pkgs/languagetool-rs {})
# (pkgs.callPackage ../pkgs/sql-language-server {})
actionlint
alejandra
cmake-format
cppcheck
luajitPackages.luacheck
nodePackages.jsonlint
pgformatter
rustfmt
shellcheck
shellharden
shfmt
sqlfluff
statix
stylua
yapf
];
};
rust-tools = {
Expand Down

0 comments on commit d8ba5e2

Please sign in to comment.