From 6d11664e7bba088746ce003a7609d7b2aee9ac0f Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Tue, 26 Mar 2024 13:04:17 +0100 Subject: [PATCH] more formatting and lsp foo --- users/common/nvim/default.nix | 3 +++ users/common/nvim/lua/plugins/conform.lua | 25 +++++++++++++++++ users/common/nvim/lua/plugins/lsp.lua | 33 +++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 users/common/nvim/lua/plugins/conform.lua diff --git a/users/common/nvim/default.nix b/users/common/nvim/default.nix index b456bee..b3f294e 100644 --- a/users/common/nvim/default.nix +++ b/users/common/nvim/default.nix @@ -16,6 +16,9 @@ cargo rust-analyzer rustfmt + # misc + nodePackages.prettier + marksman ]; plugins = with pkgs.vimPlugins; [ diff --git a/users/common/nvim/lua/plugins/conform.lua b/users/common/nvim/lua/plugins/conform.lua new file mode 100644 index 0000000..608accc --- /dev/null +++ b/users/common/nvim/lua/plugins/conform.lua @@ -0,0 +1,25 @@ +return { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + ["javascript"] = { "prettier" }, + ["javascriptreact"] = { "prettier" }, + ["typescript"] = { "prettier" }, + ["typescriptreact"] = { "prettier" }, + ["vue"] = { "prettier" }, + ["css"] = { "prettier" }, + ["scss"] = { "prettier" }, + ["less"] = { "prettier" }, + ["html"] = { "prettier" }, + ["json"] = { "prettier" }, + ["jsonc"] = { "prettier" }, + ["yaml"] = { "prettier" }, + ["markdown"] = { "prettier" }, + ["markdown.mdx"] = { "prettier" }, + ["graphql"] = { "prettier" }, + ["handlebars"] = { "prettier" }, + ["python"] = { "black" }, + }, + }, +} diff --git a/users/common/nvim/lua/plugins/lsp.lua b/users/common/nvim/lua/plugins/lsp.lua index 22ad8d2..b617ef1 100644 --- a/users/common/nvim/lua/plugins/lsp.lua +++ b/users/common/nvim/lua/plugins/lsp.lua @@ -36,6 +36,39 @@ return { }, }, }, + jsonls = { + -- lazy-load schemastore when needed + on_new_config = function(new_config) + new_config.settings.json.schemas = new_config.settings.json.schemas or {} + vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas()) + end, + settings = { + json = { + format = { + enable = true, + }, + validate = { enable = true }, + }, + }, + }, + marksman = {}, + ruff_lsp = { + keys = { + { + "co", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.organizeImports" }, + diagnostics = {}, + }, + }) + end, + desc = "Organize Imports", + }, + }, + }, }, }, },