Set up conform.nvim
This commit is contained in:
parent
445c5965c6
commit
e6f397f4be
|
@ -3,5 +3,6 @@ args: {
|
||||||
purescript = import ./purescript.nix args;
|
purescript = import ./purescript.nix args;
|
||||||
rwtw = import ./rwtw.nix args;
|
rwtw = import ./rwtw.nix args;
|
||||||
typst = import ./typst.nix args;
|
typst = import ./typst.nix args;
|
||||||
|
lua = import ./lua.nix args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
devshells/lua.nix
Normal file
8
devshells/lua.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
pkgs.mkShell {
|
||||||
|
pacakges = with pkgs; [
|
||||||
|
stylua
|
||||||
|
lua-language-server
|
||||||
|
lua
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
# shell containing the tools i most commonly use for purescript work!
|
# shell containing the tools i most commonly use for purescript work!
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
nativebuildinputs = with pkgs; [ purescript spago typescript nodejs ];
|
packages = with pkgs; [ purescript spago typescript nodejs ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
||||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||||
|
"conform": { "branch": "master", "commit": "5bf1405fd234d469243ea6f394e0aeec9ea53bd8" },
|
||||||
"crates.nvim": { "branch": "main", "commit": "d5caf28aba49e81ac4099426231f3cf3c151013a" },
|
"crates.nvim": { "branch": "main", "commit": "d5caf28aba49e81ac4099426231f3cf3c151013a" },
|
||||||
"dhall-vim": { "branch": "master", "commit": "68500ef46ff3706f46c99db3be7a0c8abcf6a3ae" },
|
"dhall-vim": { "branch": "master", "commit": "68500ef46ff3706f46c99db3be7a0c8abcf6a3ae" },
|
||||||
"dressing.nvim": { "branch": "master", "commit": "6bde51adabba06f7fd4a469885a85f36d78a5f52" },
|
"dressing.nvim": { "branch": "master", "commit": "6bde51adabba06f7fd4a469885a85f36d78a5f52" },
|
||||||
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
|
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
|
||||||
"flash": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
|
"flash": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
|
||||||
"formatter.nvim": { "branch": "master", "commit": "44c89f09dcc220dc2a9b056e93c3a87c86e79804" },
|
|
||||||
"github-actions-yaml.vim": { "branch": "master", "commit": "f2f16243447cea174daa6b4a9ffd3ff9213814ef" },
|
"github-actions-yaml.vim": { "branch": "master", "commit": "f2f16243447cea174daa6b4a9ffd3ff9213814ef" },
|
||||||
"gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
|
"gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" },
|
"gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" },
|
||||||
|
|
|
@ -6,6 +6,9 @@ local M = {}
|
||||||
M.unicode = {
|
M.unicode = {
|
||||||
-- {{{ Logic
|
-- {{{ Logic
|
||||||
{ "frl", "∀" }, -- [f]o[r]al[l]
|
{ "frl", "∀" }, -- [f]o[r]al[l]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ "exs", "∃" }, -- [e][x]ist[s]
|
{ "exs", "∃" }, -- [e][x]ist[s]
|
||||||
{ "land", "∧" }, -- [l]ogical [and]
|
{ "land", "∧" }, -- [l]ogical [and]
|
||||||
{ "Land", "⋀" }, -- arbitrary [l]ogical [and]
|
{ "Land", "⋀" }, -- arbitrary [l]ogical [and]
|
||||||
|
|
|
@ -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 })
|
vim.lsp.buf.format({ async = false, bufnr = bufnr })
|
||||||
end
|
end
|
||||||
|
|
||||||
if client.supports_method("textDocument/formatting") then
|
-- if client.supports_method("textDocument/formatting") then
|
||||||
nmap("<leader>F", format, "[F]ormat")
|
-- nmap("<leader>F", format, "[F]ormat")
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
-- group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
||||||
buffer = bufnr,
|
-- buffer = bufnr,
|
||||||
callback = format,
|
-- callback = format,
|
||||||
})
|
-- })
|
||||||
end
|
-- end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- {{{ Go to declaration / references / implementation
|
-- {{{ Go to declaration / references / implementation
|
||||||
nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition")
|
nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition")
|
||||||
|
@ -129,6 +129,10 @@ local servers = {
|
||||||
settings = {
|
settings = {
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
Lua = {
|
Lua = {
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
format = {
|
||||||
|
enable = true
|
||||||
|
},
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
-- Do not send telemetry data containing a randomized but unique identifier
|
||||||
telemetry = {
|
telemetry = {
|
||||||
enable = false,
|
enable = false,
|
||||||
|
|
|
@ -13,21 +13,7 @@ function M.config()
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
local sources = {
|
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
|
-- {{{ 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
|
-- Diagnostics
|
||||||
null_ls.builtins.diagnostics.ruff, -- Linting
|
null_ls.builtins.diagnostics.ruff, -- Linting
|
||||||
-- null_ls.builtins.diagnostics.mypy, -- Type checking
|
-- null_ls.builtins.diagnostics.mypy, -- Type checking
|
||||||
|
|
|
@ -73,7 +73,7 @@ let
|
||||||
# Required by magma-nvim:
|
# Required by magma-nvim:
|
||||||
# python310Packages.pynvim
|
# python310Packages.pynvim
|
||||||
# python310Packages.jupyter
|
# python310Packages.jupyter
|
||||||
];
|
] ++ config.satellite.neovim.generated.dependencies;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ extraRuntime
|
# {{{ extraRuntime
|
||||||
extraRuntimePaths = env: [
|
extraRuntimePaths = env: [
|
||||||
|
@ -268,7 +268,7 @@ in
|
||||||
package = "folke/flash.nvim";
|
package = "folke/flash.nvim";
|
||||||
name = "flash";
|
name = "flash";
|
||||||
|
|
||||||
cond = nlib.blacklistEnv [ "vscode" "firenvim" ];
|
cond = nlib.blacklistEnv [ "vscode" ];
|
||||||
keys =
|
keys =
|
||||||
let keybind = mode: mapping: action: desc: {
|
let keybind = mode: mapping: action: desc: {
|
||||||
inherit mapping desc mode;
|
inherit mapping desc mode;
|
||||||
|
@ -287,5 +287,22 @@ in
|
||||||
opts.modes.char.enabled = false;
|
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" ] ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,13 +215,13 @@ let
|
||||||
numberOr = luaEncoders.conditional (e: lib.isFloat e || lib.isInt e) luaEncoders.number;
|
numberOr = luaEncoders.conditional (e: lib.isFloat e || lib.isInt e) luaEncoders.number;
|
||||||
nullOr = luaEncoders.conditional (e: e == null) luaEncoders.nil;
|
nullOr = luaEncoders.conditional (e: e == null) luaEncoders.nil;
|
||||||
anything = lib.pipe (luaEncoders.fail (v: "Cannot figure out how to encode value ${builtins.toJSON v}")) [
|
anything = lib.pipe (luaEncoders.fail (v: "Cannot figure out how to encode value ${builtins.toJSON v}")) [
|
||||||
luaEncoders.luaCodeOr
|
(luaEncoders.attrsetOfOr luaEncoders.anything)
|
||||||
|
(luaEncoders.listOfOr luaEncoders.anything)
|
||||||
luaEncoders.nullOr
|
luaEncoders.nullOr
|
||||||
luaEncoders.boolOr
|
luaEncoders.boolOr
|
||||||
luaEncoders.numberOr
|
luaEncoders.numberOr
|
||||||
luaEncoders.stringOr
|
luaEncoders.stringOr
|
||||||
(luaEncoders.listOfOr luaEncoders.anything)
|
luaEncoders.luaCodeOr # Lua code expressions have priority over attrsets
|
||||||
(luaEncoders.attrsetOfOr luaEncoders.anything)
|
|
||||||
];
|
];
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Lua code
|
# {{{ Lua code
|
||||||
|
@ -340,6 +340,12 @@ in
|
||||||
type = types.package;
|
type = types.package;
|
||||||
description = "Derivation building all the given nix modules";
|
description = "Derivation building all the given nix modules";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dependencies = lib.mkOption {
|
||||||
|
default = [ ];
|
||||||
|
type = types.listOf types.package;
|
||||||
|
description = "List of packages to give neovim access to";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
lib = {
|
lib = {
|
||||||
|
@ -432,4 +438,12 @@ in
|
||||||
name = "lazy-nvim-modules";
|
name = "lazy-nvim-modules";
|
||||||
paths = lib.attrsets.mapAttrsToList (_: m: m.module) cfg.generated.lazy;
|
paths = lib.attrsets.mapAttrsToList (_: m: m.module) cfg.generated.lazy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config.satellite.neovim.generated.dependencies =
|
||||||
|
lib.pipe cfg.lazy
|
||||||
|
[
|
||||||
|
(lib.attrsets.mapAttrsToList (_: m: m.dependencies.nix))
|
||||||
|
lib.lists.flatten
|
||||||
|
]
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
# Enable experimental features without having to specify the argument
|
# Enable experimental features without having to specify the argument
|
||||||
NIX_CONFIG = "experimental-features = nix-command flakes";
|
NIX_CONFIG = "experimental-features = nix-command flakes";
|
||||||
nativeBuildInputs = with pkgs; [ nix home-manager git ];
|
packages = with pkgs; [ nix home-manager git ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue