Set up conform.nvim
This commit is contained in:
parent
445c5965c6
commit
e6f397f4be
11 changed files with 68 additions and 77 deletions
home/features/neovim
config
default.nix
|
@ -9,12 +9,12 @@
|
|||
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||
"conform": { "branch": "master", "commit": "5bf1405fd234d469243ea6f394e0aeec9ea53bd8" },
|
||||
"crates.nvim": { "branch": "main", "commit": "d5caf28aba49e81ac4099426231f3cf3c151013a" },
|
||||
"dhall-vim": { "branch": "master", "commit": "68500ef46ff3706f46c99db3be7a0c8abcf6a3ae" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "6bde51adabba06f7fd4a469885a85f36d78a5f52" },
|
||||
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
|
||||
"flash": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
|
||||
"formatter.nvim": { "branch": "master", "commit": "44c89f09dcc220dc2a9b056e93c3a87c86e79804" },
|
||||
"github-actions-yaml.vim": { "branch": "master", "commit": "f2f16243447cea174daa6b4a9ffd3ff9213814ef" },
|
||||
"gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" },
|
||||
|
|
|
@ -6,7 +6,10 @@ local M = {}
|
|||
M.unicode = {
|
||||
-- {{{ Logic
|
||||
{ "frl", "∀" }, -- [f]o[r]al[l]
|
||||
{ "exs", "∃" }, -- [e][x]ist[s]
|
||||
|
||||
|
||||
|
||||
{ "exs", "∃" }, -- [e][x]ist[s]
|
||||
{ "land", "∧" }, -- [l]ogical [and]
|
||||
{ "Land", "⋀" }, -- arbitrary [l]ogical [and]
|
||||
{ "lor", "∨" }, -- [l]ogical [or]
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
local env = require("my.helpers.env")
|
||||
local K = require("my.keymaps")
|
||||
|
||||
local M = {
|
||||
"mhartington/formatter.nvim",
|
||||
event = "BufReadPre",
|
||||
cond = env.vscode.not_active(),
|
||||
}
|
||||
|
||||
function M.config()
|
||||
local any = require("formatter.filetypes.any")
|
||||
local formatters = {
|
||||
markdown = {
|
||||
require("formatter.filetypes.markdown").prettier,
|
||||
},
|
||||
lua = {
|
||||
require("formatter.filetypes.lua").stylua,
|
||||
},
|
||||
["*"] = {
|
||||
any.remove_trailing_whitespace,
|
||||
},
|
||||
}
|
||||
|
||||
require("formatter").setup({ filetype = formatters })
|
||||
|
||||
local format = function()
|
||||
if formatters[vim.bo.filetype] ~= nil then
|
||||
vim.cmd([[Format]])
|
||||
elseif next(vim.lsp.get_active_clients({ bufnr = 0 })) == nil then
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
end
|
||||
|
||||
K.nmap("<leader>F", format, "[F]ormat file")
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("Formatting", { clear = false }),
|
||||
callback = format,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
|
@ -42,14 +42,14 @@ function M.on_attach(client, bufnr)
|
|||
vim.lsp.buf.format({ async = false, bufnr = bufnr })
|
||||
end
|
||||
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
nmap("<leader>F", format, "[F]ormat")
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
||||
buffer = bufnr,
|
||||
callback = format,
|
||||
})
|
||||
end
|
||||
-- if client.supports_method("textDocument/formatting") then
|
||||
-- nmap("<leader>F", format, "[F]ormat")
|
||||
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
-- group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
||||
-- buffer = bufnr,
|
||||
-- callback = format,
|
||||
-- })
|
||||
-- end
|
||||
-- }}}
|
||||
-- {{{ Go to declaration / references / implementation
|
||||
nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition")
|
||||
|
@ -129,6 +129,10 @@ local servers = {
|
|||
settings = {
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
Lua = {
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
format = {
|
||||
enable = true
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
|
@ -211,9 +215,9 @@ function lspconfig.config()
|
|||
diagnostics_icons()
|
||||
-- -- {{{ Change on-hover borders
|
||||
vim.lsp.handlers["textDocument/hover"] =
|
||||
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
|
||||
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] =
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" })
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" })
|
||||
-- -- }}}
|
||||
|
||||
local capabilities = M.capabilities()
|
||||
|
@ -226,7 +230,7 @@ function lspconfig.config()
|
|||
|
||||
require("lspconfig")[lsp].setup({
|
||||
on_attach = details.on_attach,
|
||||
settings = details.settings, -- Specific per-language settings
|
||||
settings = details.settings, -- Specific per-language settings
|
||||
flags = {
|
||||
debounce_text_changes = 150, -- This will be the default in neovim 0.7+
|
||||
},
|
||||
|
|
|
@ -13,21 +13,7 @@ function M.config()
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
local sources = {
|
||||
-- {{{ Typescript formatting
|
||||
-- null_ls.builtins.formatting.prettierd, -- format ts files
|
||||
null_ls.builtins.formatting.prettier, -- format ts files
|
||||
-- }}}
|
||||
-- {{{ Lua formatting
|
||||
-- null_ls.builtins.formatting, -- format lua code
|
||||
null_ls.builtins.formatting.stylua, -- format lua code
|
||||
-- }}}
|
||||
-- {{{ Python
|
||||
-- Formatting:
|
||||
-- null_ls.builtins.formatting.black,
|
||||
-- null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.yapf.with({
|
||||
extra_args = { [[--style="{ indent_width: 2 }"]] },
|
||||
}),
|
||||
-- Diagnostics
|
||||
null_ls.builtins.diagnostics.ruff, -- Linting
|
||||
-- null_ls.builtins.diagnostics.mypy, -- Type checking
|
||||
|
|
|
@ -73,7 +73,7 @@ let
|
|||
# Required by magma-nvim:
|
||||
# python310Packages.pynvim
|
||||
# python310Packages.jupyter
|
||||
];
|
||||
] ++ config.satellite.neovim.generated.dependencies;
|
||||
# }}}
|
||||
# {{{ extraRuntime
|
||||
extraRuntimePaths = env: [
|
||||
|
@ -268,7 +268,7 @@ in
|
|||
package = "folke/flash.nvim";
|
||||
name = "flash";
|
||||
|
||||
cond = nlib.blacklistEnv [ "vscode" "firenvim" ];
|
||||
cond = nlib.blacklistEnv [ "vscode" ];
|
||||
keys =
|
||||
let keybind = mode: mapping: action: desc: {
|
||||
inherit mapping desc mode;
|
||||
|
@ -287,5 +287,22 @@ in
|
|||
opts.modes.char.enabled = false;
|
||||
};
|
||||
# }}}
|
||||
# {{{ Conform.nvim
|
||||
satellite.neovim.lazy.conform = {
|
||||
package = "stevearc/conform.nvim";
|
||||
name = "conform";
|
||||
|
||||
cond = nlib.blacklistEnv [ "vscode" ];
|
||||
event = "BufReadPost";
|
||||
|
||||
opts.log_level = nlib.lua "vim.log.levels.DEBUG";
|
||||
opts.format_on_save.lsp_fallback = true;
|
||||
opts.formatters_by_ft = {
|
||||
lua = [ "stylua" ];
|
||||
python = [ "ruff_format" ];
|
||||
javascript = [ [ "prettierd" "prettier" ] ];
|
||||
};
|
||||
};
|
||||
# }}}
|
||||
# }}}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue