From 81e111c01e5b463a83462a7f0c62a00d1dd831c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BB=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC?= Date: Tue, 2 Jun 2026 14:49:22 +0300 Subject: [PATCH] feat(lsp): Set up vtsls, vue_ls, install miscellaneous plugins --- after/lsp/lua_ls.lua | 24 ++++++++++++++--------- after/lsp/vtsls.lua | 41 +++++++++++++++++++++++++++++++++++++++ after/lsp/vue_ls.lua | 2 ++ after/plugin/gitsigns.lua | 8 ++++++++ after/plugin/lualine.lua | 3 +++ after/plugin/null_ls.lua | 12 ++++++++++++ after/plugin/tree.lua | 28 ++++++++++++++++++++++++++ init.lua | 4 ++++ lua/formatting.lua | 14 ++++++++++++- lua/lsp.lua | 19 +++++++++++++++++- lua/plugins.lua | 7 +++++++ nvim-pack-lock.json | 20 +++++++++++++++++++ 12 files changed, 171 insertions(+), 11 deletions(-) create mode 100644 after/lsp/vtsls.lua create mode 100644 after/lsp/vue_ls.lua create mode 100644 after/plugin/gitsigns.lua create mode 100644 after/plugin/lualine.lua create mode 100644 after/plugin/null_ls.lua create mode 100644 after/plugin/tree.lua diff --git a/after/lsp/lua_ls.lua b/after/lsp/lua_ls.lua index cfcb41f..3e265a0 100644 --- a/after/lsp/lua_ls.lua +++ b/after/lsp/lua_ls.lua @@ -1,14 +1,20 @@ ---@type vim.lsp.Config local settings = { - ---@type lspconfig.settings.lua_ls - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - }, - workspace = { checkThirdParty = false, library = vim.list_extend({ vim.fn.expand('$VIMRUNTIME') }, vim.api.nvim_get_runtime_file('lua', true)) }, - }, - }, + ---@type lspconfig.settings.lua_ls + settings = { + Lua = { + hint = { + enable = true, + }, + runtime = { + version = "LuaJIT", + }, + workspace = { + checkThirdParty = false, + library = vim.list_extend({ vim.fn.expand("$VIMRUNTIME") }, vim.api.nvim_get_runtime_file("lua", true)), + }, + }, + }, } return settings diff --git a/after/lsp/vtsls.lua b/after/lsp/vtsls.lua new file mode 100644 index 0000000..fc91696 --- /dev/null +++ b/after/lsp/vtsls.lua @@ -0,0 +1,41 @@ +---@type lspconfig.Config +return { + filetypes = { + "javascript", + "typescript", + "vue", + }, + settings = { + ---@type lspconfig.settings.vtsls + vtsls = { + tsserver = { + globalPlugins = { + { + name = "@vue/typescript-plugin", + location = require("mason-registry").get_package("vue-language-server"):get_install_path(), + languages = { "vue" }, + configNamespace = "typescript", + }, + }, + }, + suggest = { + autoImports = true, + }, + updateImportsOnFileMove = { enabled = "always" }, + inlayHints = { + enumMemberValues = { + enabled = true, + }, + parameterNames = { + enabled = "literals", + }, + parameterTypes = { + enabled = true, + }, + propertyDeclarationTypes = { + enabled = true, + }, + }, + }, + }, +} diff --git a/after/lsp/vue_ls.lua b/after/lsp/vue_ls.lua new file mode 100644 index 0000000..f97e425 --- /dev/null +++ b/after/lsp/vue_ls.lua @@ -0,0 +1,2 @@ +---@type lspconfig.Config +return {} diff --git a/after/plugin/gitsigns.lua b/after/plugin/gitsigns.lua new file mode 100644 index 0000000..bed13bc --- /dev/null +++ b/after/plugin/gitsigns.lua @@ -0,0 +1,8 @@ +local gitsigns = require("gitsigns") + +gitsigns.setup({ + current_line_blame = true, + current_line_blame_opts = { + delay = 100, + }, +}) diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua new file mode 100644 index 0000000..fa55534 --- /dev/null +++ b/after/plugin/lualine.lua @@ -0,0 +1,3 @@ +local lualine = require("lualine") + +lualine.setup({}) diff --git a/after/plugin/null_ls.lua b/after/plugin/null_ls.lua new file mode 100644 index 0000000..87b8aaa --- /dev/null +++ b/after/plugin/null_ls.lua @@ -0,0 +1,12 @@ +local null_ls = require("null-ls") + +local options = { + sources = { + null_ls.builtins.diagnostics.phpcs.with({ + command = "phpcs", + args = { "--report=json", "--stdin-path=$FILENAME", "-" }, + }), + }, +} + +null_ls.setup(options) diff --git a/after/plugin/tree.lua b/after/plugin/tree.lua new file mode 100644 index 0000000..39d3bc6 --- /dev/null +++ b/after/plugin/tree.lua @@ -0,0 +1,28 @@ +local tree = require("nvim-tree") +local utils = require("utils") +local api = require("nvim-tree.api") + +local function on_attach(bufnr) + api.map.on_attach.default(bufnr) +end + +---@type nvim_tree.config +local options = { + update_focused_file = { + enable = true, + exclude = function(args) + for _, dir in ipairs({ "node_modules", "vendor", ".git" }) do + if args.file:find(dir, 1, true) then + return true + end + end + + return false + end, + }, + on_attach = on_attach, +} + +tree.setup(options) + +utils.nmap("e", api.tree.toggle, "nvim-tree: toggle") diff --git a/init.lua b/init.lua index 3da74a1..4d284cc 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,7 @@ +-- Disable netrw +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + vim.g.mapleader = " " vim.g.localmapleader = " " diff --git a/lua/formatting.lua b/lua/formatting.lua index 58d29dc..61da9af 100644 --- a/lua/formatting.lua +++ b/lua/formatting.lua @@ -2,11 +2,23 @@ local conform = require("conform") ---@type conform.setupOpts local options = { + formatters = { + phpcbf = { + command = "phpcbf", + args = { "-" }, + stdin = true, + exist_codes = { 0, 1 }, + }, + }, formatters_by_ft = { lua = { "stylua" }, + php = { "phpcbf" }, + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + vue = { "eslint_d" }, }, format_on_save = { - timeout_ms = 500, + timeout_ms = 5000, lsp_format = "fallback", }, } diff --git a/lua/lsp.lua b/lua/lsp.lua index dc00bb2..428294e 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -5,16 +5,33 @@ require("mason-lspconfig").setup({ "lua_ls", "stylua", "intelephense", + "eslint", + "vtsls", + "vue_ls", }, }) + local telescope = require("telescope.builtin") vim.api.nvim_create_autocmd("LspAttach", { - desc = "LSP Keymaps", + desc = "LspAttach", callback = function(args) local bufnr = args.buf local options = { buffer = bufnr } + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + vim.diagnostic.config({ + virtual_text = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "\u{F057}", + [vim.diagnostic.severity.WARN] = "\u{F071}", + [vim.diagnostic.severity.HINT] = "\u{F0EB}", + [vim.diagnostic.severity.INFO] = "\u{F05A}", + }, + }, + }) + -- Navigation utils.nmap("gt", telescope.lsp_type_definitions, "Go to Type Definition", options) utils.nmap("gd", telescope.lsp_definitions, "Go to Definition", options) diff --git a/lua/plugins.lua b/lua/plugins.lua index 2cb3ed9..40cfc46 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -21,6 +21,9 @@ vim.pack.add({ -- Code formatting { src = "https://github.com/stevearc/conform.nvim" }, + -- Code linting (non-LSP sources) + { src = "https://github.com/nvimtools/none-ls.nvim" }, + -- Appearance { src = "https://github.com/rose-pine/neovim", name = "rose-pine" }, { src = "https://github.com/nvim-tree/nvim-web-devicons" }, @@ -32,6 +35,10 @@ vim.pack.add({ -- Miscellaneous { src = "https://github.com/windwp/nvim-autopairs" }, { src = "https://github.com/folke/which-key.nvim" }, + { src = "https://github.com/nvim-lualine/lualine.nvim" }, + { src = "https://github.com/nvim-tree/nvim-tree.lua" }, + { src = "https://github.com/tpope/vim-fugitive" }, + { src = "https://github.com/lewis6991/gitsigns.nvim" }, -- WoW Addon API { src = "https://github.com/Tyrannican/warcraft-api.nvim" }, diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index c5d2eb2..fa92c2d 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -12,6 +12,14 @@ "rev": "619363c30309d29ffa631e67c8183f2a72caa373", "src": "https://github.com/stevearc/conform.nvim" }, + "gitsigns.nvim": { + "rev": "dd3f588bacbeb041be6facf1742e42097f62165d", + "src": "https://github.com/lewis6991/gitsigns.nvim" + }, + "lualine.nvim": { + "rev": "221ce6b2d999187044529f49da6554a92f740a96", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, "mason-lspconfig.nvim": { "rev": "0a695750d747db1e7e70bcf0267ef8951c95fc83", "src": "https://github.com/mason-org/mason-lspconfig.nvim" @@ -20,6 +28,10 @@ "rev": "16ba83bfc8a25f52bb545134f5bee082b195c460", "src": "https://github.com/mason-org/mason.nvim" }, + "none-ls.nvim": { + "rev": "f9d557ac7cd28a3a993b5ea49716498bd540b01f", + "src": "https://github.com/nvimtools/none-ls.nvim" + }, "nvim-autopairs": { "rev": "7b9923abad60b903ece7c52940e1321d39eccc79", "src": "https://github.com/windwp/nvim-autopairs" @@ -28,6 +40,10 @@ "rev": "9573948c38bfabeec353ae7dd7d3ffec4c506a6b", "src": "https://github.com/neovim/nvim-lspconfig" }, + "nvim-tree.lua": { + "rev": "07f541fcaa4a5ae019598240362449ab7e9812b3", + "src": "https://github.com/nvim-tree/nvim-tree.lua" + }, "nvim-web-devicons": { "rev": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c", "src": "https://github.com/nvim-tree/nvim-web-devicons" @@ -52,6 +68,10 @@ "rev": "bb66b815aff01e87b2e26be995116be8d2f91474", "src": "https://github.com/romus204/tree-sitter-manager.nvim" }, + "vim-fugitive": { + "rev": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0", + "src": "https://github.com/tpope/vim-fugitive" + }, "warcraft-api.nvim": { "rev": "c016bc54ed62bca5058cc3bd7553e429dd8caf37", "src": "https://github.com/Tyrannican/warcraft-api.nvim"