From 3d9677192a225903529a437e6974fa97efffd675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Wed, 23 Oct 2024 11:52:30 +0200 Subject: [PATCH] Add typescript + jinja LSP. --- after/ftplugin/typescript.vim | 2 + after/ftplugin/vue.vim | 2 + lazy-lock.json | 5 ++ lua/configs/lspconfig.lua | 44 ++++++++++++++++-- lua/configs/mason-lspconfig.lua | 3 ++ lua/configs/mason.lua | 2 +- lua/configs/telescope/commands.lua | 1 + lua/configs/telescope/init.lua | 1 + lua/plugins/init.lua | 75 ++++++++++++++++++++++++++++++ 9 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 after/ftplugin/typescript.vim create mode 100644 after/ftplugin/vue.vim create mode 100644 lua/configs/mason-lspconfig.lua diff --git a/after/ftplugin/typescript.vim b/after/ftplugin/typescript.vim new file mode 100644 index 0000000..884dc4c --- /dev/null +++ b/after/ftplugin/typescript.vim @@ -0,0 +1,2 @@ +setlocal tabstop=2 +setlocal shiftwidth=2 diff --git a/after/ftplugin/vue.vim b/after/ftplugin/vue.vim new file mode 100644 index 0000000..884dc4c --- /dev/null +++ b/after/ftplugin/vue.vim @@ -0,0 +1,2 @@ +setlocal tabstop=2 +setlocal shiftwidth=2 diff --git a/lazy-lock.json b/lazy-lock.json index f349911..4d30bad 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -10,6 +10,7 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "667102f26106709cddd2dff1f699610df5b94d7f" }, + "csvview.nvim": { "branch": "main", "commit": "f4dcf942fe94c713f012918dbae569ef3109b20c" }, "diaglist.nvim": { "branch": "master", "commit": "afc124a0976d56db43cc840e62757193ccab7856" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, @@ -23,6 +24,7 @@ "macrothis.nvim": { "branch": "main", "commit": "3fe6af86ce9eb509737f7955007c58dec96eb02b" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "marks.nvim": { "branch": "master", "commit": "74e8d01b2a2131b6e46354cffc553aa7f81bcf5b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "noice.nvim": { "branch": "main", "commit": "448bb9c524a7601035449210838e374a30153172" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, @@ -32,6 +34,7 @@ "nvim-dap": { "branch": "master", "commit": "2b428ff2632e73295e9decbcf1c40d8e26213305" }, "nvim-dap-python": { "branch": "master", "commit": "d777c2b32ed39f61209c09bede28d7491621a631" }, "nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" }, + "nvim-dbee": { "branch": "master", "commit": "21d2cc0844a16262bb6ea93ab3d0a0f20bd87853" }, "nvim-lint": { "branch": "master", "commit": "ad0fe35e80f5cd31a0f19176d7b30e5c3011119d" }, "nvim-lspconfig": { "branch": "master", "commit": "037ea0901ce9a28cfcaa36302618f06d2e164fbf" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, @@ -43,6 +46,7 @@ "persistent-breakpoints.nvim": { "branch": "main", "commit": "4b199b1dcfd136cac8b0fa9c8dbbdeb81463f7a9" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "quicker.nvim": { "branch": "master", "commit": "6b79167543f1b18e76319217a29bb4e177a5e1ae" }, + "rainbow_csv.nvim": { "branch": "main", "commit": "7f3fddfe813641035fac2cdf94c2ff69bb0bf0b9" }, "rgflow.nvim": { "branch": "master", "commit": "8a2d80b8594591163d06b430be18c7376d5ae1b8" }, "tagbar": { "branch": "master", "commit": "d55d454bd3d5b027ebf0e8c75b8f88e4eddad8d8" }, "telescope-dap.nvim": { "branch": "master", "commit": "8c88d9716c91eaef1cdea13cb9390d8ef447dbfe" }, @@ -51,6 +55,7 @@ "telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" }, "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "typescript-tools.nvim": { "branch": "master", "commit": "f8c2e0b36b651c85f52ad5c5373ff8b07adc15a7" }, "ui": { "branch": "v2.5", "commit": "6783a3ab3d9bf22859234dd2196888da1d0f0426" }, "vim-autoswap": { "branch": "master", "commit": "e587e4b14a605d8921942ba65a37583813289272" }, "vim-flog": { "branch": "master", "commit": "8520904c8b37fe74824f1c46ba73f75158d7ae3b" }, diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 0012de0..6dfce72 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -4,7 +4,7 @@ require("nvchad.configs.lspconfig").defaults() local lspconfig = require "lspconfig" -- EXAMPLE -local servers = { "html", "cssls" } +local servers = { "html", "cssls", "volar", "typescript-tools", "tsserver" } local nvlsp = require "nvchad.configs.lspconfig" -- lsps with default config @@ -39,15 +39,20 @@ require("lspconfig").pyright.setup { -- ignore = { "*" }, -- using ruff -- typecheckingmode = "off", -- using mypy diagnosticseverityoverrides = { - reportmissingimports = false, - -- reportattributeaccessissue = false, + reportMissingImports = false, reportUnusedVariable = false, + reportIncompatibleVariableOverride = false, + -- reportAttributeAccessIssue = false, }, }, }, }, } +-- require("lspconfig").tsserver.setup { +-- filetypes = { "html", "javascript", "htmldjango" }, +-- } + -- require("lspconfig").pylsp.setup { -- settings = { -- pylsp = { @@ -60,3 +65,36 @@ require("lspconfig").pyright.setup { -- }, -- }, -- } +-- + +local configs = require "lspconfig.configs" + +if not configs.jinja_lsp then + configs.jinja_lsp = { + default_config = { + name = "jinja-lsp", + cmd = { "/home/legrems/.cargo/bin/jinja-lsp" }, + filetypes = { "jinja", "rust", "htmldjango", "javascript" }, + root_dir = function() + return "." + end, + init_options = { + templates = "./templates", + backend = { "./src" }, + lang = "rust", + }, + }, + } +end + +local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + +lspconfig.jinja_lsp.setup { + capabilities = capabilities, +} + +lspconfig.tailwindcss.setup { + cmd = { "tailwindcss-language-server", "--stdio" }, + filetypes = { "html", "css", "javascript", "htmldjango" }, + root_dir = lspconfig.util.root_pattern("tailwind.config.js", "tailwind.config.cjs", "tailwind.config.ts"), +} diff --git a/lua/configs/mason-lspconfig.lua b/lua/configs/mason-lspconfig.lua new file mode 100644 index 0000000..5eff5cc --- /dev/null +++ b/lua/configs/mason-lspconfig.lua @@ -0,0 +1,3 @@ +return { + ensure_installed = { "lua_ls", "ts_ls" }, +} diff --git a/lua/configs/mason.lua b/lua/configs/mason.lua index 2850f72..247e7ec 100644 --- a/lua/configs/mason.lua +++ b/lua/configs/mason.lua @@ -1,5 +1,5 @@ local options = { - ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + ensure_installed = { "lua-language-server", "jinja-lsp" }, -- not an option from mason.nvim PATH = "prepand", diff --git a/lua/configs/telescope/commands.lua b/lua/configs/telescope/commands.lua index e86fc7e..4f9f539 100644 --- a/lua/configs/telescope/commands.lua +++ b/lua/configs/telescope/commands.lua @@ -1,3 +1,4 @@ return { { "Replace {{X}} with {{ X }} in jinja template", "%s/{{\\(.[^ ]*\\)}}/{{ \\1 }}/g" }, + { "Replace a text newline with a carriage return", "%s/\\\\n/\\r/g" }, } diff --git a/lua/configs/telescope/init.lua b/lua/configs/telescope/init.lua index 74c99d1..1098fca 100644 --- a/lua/configs/telescope/init.lua +++ b/lua/configs/telescope/init.lua @@ -293,6 +293,7 @@ local options = { [""] = custom_actions.multi_selection_vsplit, [""] = custom_actions.multi_selection_split, [""] = custom_actions.multi_selection_tab, + -- [""] = custom_actions.set_extension_files, }, n = i, }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index fd79b2d..00b140c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -205,6 +205,12 @@ return { end, }, + { + "pmizio/typescript-tools.nvim", + dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + opts = {}, + }, + -- lsp stuff { "williamboman/mason.nvim", @@ -214,6 +220,14 @@ return { end, }, + { + "williamboman/mason-lspconfig.nvim", + lazy = false, + opts = function() + return require "configs.mason-lspconfig" + end, + }, + { "neovim/nvim-lspconfig", event = "User FilePost", @@ -305,6 +319,7 @@ return { { "sindrets/winshift.nvim", + lazy = false, }, { @@ -398,4 +413,64 @@ return { cmd = "Trouble", opts = {}, }, + { + "kndndrj/nvim-dbee", + dependencies = { + "MunifTanjim/nui.nvim", + }, + build = function() + -- Install tries to automatically detect the install method. + -- if it fails, try calling it with one of these parameters: + -- "curl", "wget", "bitsadmin", "go" + require("dbee").install() + end, + config = function() + require("dbee").setup { + + sources = { + require("dbee.sources").MemorySource:new { + { + name = "localhost", + type = "postgres", + url = "postgres://postgres:123@localhost:5432/gestion-isp?sslmode=disable", + }, + -- ... + }, + }, + } + end, + }, + { + "hat0uma/csvview.nvim", + config = function() + require("csvview").setup() + end, + init = function() + require("csvview").setup { + view = { + display_mode = "border", + }, + } + end, + }, + { + "cameron-wags/rainbow_csv.nvim", + config = true, + lazy = false, + ft = { + "csv", + "tsv", + "csv_semicolon", + "csv_whitespace", + "csv_pipe", + "rfc_csv", + "rfc_semicolon", + }, + cmd = { + "RainbowDelim", + "RainbowDelimSimple", + "RainbowDelimQuoted", + "RainbowMultiDelim", + }, + }, }