Compare commits
13 Commits
d73bcbaa9b
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dab9b2499 | |||
| 0f73cbcb92 | |||
| fc930deb4b | |||
| 459fa712d9 | |||
| 6f1adc9381 | |||
| 1af2b4cc7d | |||
| 018b471b72 | |||
| 7f725c6530 | |||
| 508ebdb0c0 | |||
| 4d56666323 | |||
| 306fa774af | |||
| 9a2b77fe5f | |||
| c0ae23a60d |
@@ -24,4 +24,4 @@ if not pcall(require, "lazy") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
require "lazy_setup"
|
require "lazy_setup"
|
||||||
require "polish"
|
require "polish.init"
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
{
|
|
||||||
"AstroNvim": { "branch": "main", "commit": "8246795ea910498211b7e14822bc7831bc015b5d" },
|
|
||||||
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
|
|
||||||
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
|
|
||||||
"aerial.nvim": { "branch": "master", "commit": "d8343d0c935a72382413f9344ae0e39072405b7d" },
|
|
||||||
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
|
|
||||||
"astrocommunity": { "branch": "main", "commit": "5f74d5fb8d8dc9b8e2904846809121068d7afaca" },
|
|
||||||
"astrocore": { "branch": "main", "commit": "44a3dc0bf1591022b2a6bc89dccdfac1be17bec9" },
|
|
||||||
"astrolsp": { "branch": "main", "commit": "fd2666a283af98182b1e8b01c85656071093a825" },
|
|
||||||
"astrotheme": { "branch": "main", "commit": "ab0cb19c32181126f92b8239700cec97ba81b0fd" },
|
|
||||||
"astroui": { "branch": "main", "commit": "e923a84c488d879a260fc9cfb2dc27dd870fb6ac" },
|
|
||||||
"better-escape.nvim": { "branch": "master", "commit": "7e86edafb8c7e73699e0320f225464a298b96d12" },
|
|
||||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
|
||||||
"cmp-dap": { "branch": "master", "commit": "ea92773e84c0ad3288c3bc5e452ac91559669087" },
|
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
|
||||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
|
||||||
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
|
|
||||||
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
|
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" },
|
|
||||||
"guess-indent.nvim": { "branch": "main", "commit": "6c75506e71836f34fe5c5efa322dfce3e0494e7b" },
|
|
||||||
"heirline.nvim": { "branch": "master", "commit": "fae936abb5e0345b85c3a03ecf38525b0828b992" },
|
|
||||||
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
|
||||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
|
||||||
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
|
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
|
|
||||||
"mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" },
|
|
||||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
|
|
||||||
"mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" },
|
|
||||||
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
|
|
||||||
"mini.bufremove": { "branch": "main", "commit": "931a3bb514147d9e812767275c4beba6b779b1d3" },
|
|
||||||
"neo-tree.nvim": { "branch": "main", "commit": "cea666ef965884414b1b71f6b39a537f9238bdb2" },
|
|
||||||
"neoconf.nvim": { "branch": "main", "commit": "054c602dcf143337151ecaa7fd4465ecfa7d27f0" },
|
|
||||||
"neodev.nvim": { "branch": "main", "commit": "1f4ebcc10852518166ce165e57d425a4265a10d4" },
|
|
||||||
"none-ls.nvim": { "branch": "main", "commit": "0d1b3fa2ad0b371b94cb4b9a27ba6e5a1a915c91" },
|
|
||||||
"nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" },
|
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
|
|
||||||
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
|
||||||
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
|
|
||||||
"nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" },
|
|
||||||
"nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" },
|
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "53a3c6444ec5006b567071614c83edc8ad651f6d" },
|
|
||||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
|
||||||
"nvim-notify": { "branch": "master", "commit": "a3020c2cf4dfc4c4f390c4a21e84e35e46cf5d17" },
|
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "ffd7725102f47e7391d7a5e7621d178689602a52" },
|
|
||||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
|
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" },
|
|
||||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
|
|
||||||
"nvim-ufo": { "branch": "main", "commit": "61463090a4f55f5d080236ea62f09d1cd8976ff3" },
|
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
|
|
||||||
"nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" },
|
|
||||||
"pendulum-nvim": { "branch": "main", "commit": "b884353d7c3e7a6fde477d8adcf0d0acf5ed077d" },
|
|
||||||
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
|
||||||
"promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" },
|
|
||||||
"resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" },
|
|
||||||
"smart-splits.nvim": { "branch": "master", "commit": "ddb23c1a1cf1507bda487cda7f6e4690965ef9f5" },
|
|
||||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
|
|
||||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
|
||||||
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
|
|
||||||
"toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" },
|
|
||||||
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
|
|
||||||
"which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }
|
|
||||||
}
|
|
||||||
+75
-5
@@ -2,10 +2,80 @@
|
|||||||
-- We import this file in `lazy_setup.lua` before the `plugins/` folder.
|
-- We import this file in `lazy_setup.lua` before the `plugins/` folder.
|
||||||
-- This guarantees that the specs are processed before any user plugins.
|
-- This guarantees that the specs are processed before any user plugins.
|
||||||
|
|
||||||
---@type LazySpec
|
--- @alias FrameworkModuleSpec { import: string }
|
||||||
return {
|
|
||||||
"AstroNvim/astrocommunity",
|
--- @alias FrameworkModules table<string, FrameworkModuleSpec[]>
|
||||||
|
|
||||||
|
-- Framework-specific community module configurations
|
||||||
|
--- @type FrameworkModules
|
||||||
|
local FRAMEWORK_COMMUNITY_MODULES = {
|
||||||
|
-- Base Lua pack - always included
|
||||||
|
lua = {
|
||||||
{ import = "astrocommunity.pack.lua" },
|
{ import = "astrocommunity.pack.lua" },
|
||||||
-- { import = "astrocommunity.completion.avante-nvim" },
|
},
|
||||||
-- import/override with your plugins folder
|
|
||||||
|
-- Vue.js framework modules
|
||||||
|
vue = {
|
||||||
|
{ import = "astrocommunity.pack.vue" },
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Retrieves the appropriate community modules based on the current framework environment
|
||||||
|
--- @return LazySpec[] List of community modules to import for the detected framework
|
||||||
|
local function get_framework_modules()
|
||||||
|
--- @type string|nil
|
||||||
|
local current_framework = os.getenv "FRAMEWORK"
|
||||||
|
--- @type LazySpec[]
|
||||||
|
local modules = {}
|
||||||
|
|
||||||
|
-- Always include base Lua pack
|
||||||
|
for _, module in ipairs(FRAMEWORK_COMMUNITY_MODULES.lua) do
|
||||||
|
table.insert(modules, module)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If framework is not set or empty string, use only base modules
|
||||||
|
if not current_framework or current_framework == "" then return modules end
|
||||||
|
|
||||||
|
-- Check if framework is valid (vue or python)
|
||||||
|
if current_framework ~= "vue" and current_framework ~= "python" then
|
||||||
|
error("Invalid framework: '" .. current_framework .. "'. Valid frameworks are: vue, python")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add framework-specific modules if framework is valid
|
||||||
|
if FRAMEWORK_COMMUNITY_MODULES[current_framework] then
|
||||||
|
for _, module in ipairs(FRAMEWORK_COMMUNITY_MODULES[current_framework]) do
|
||||||
|
table.insert(modules, module)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return modules
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if third-party AI assistant is enabled and adds Avante-nvim if true
|
||||||
|
--- @return LazySpec|nil Avante-nvim module if AI is enabled, nil otherwise
|
||||||
|
local function get_ai_modules()
|
||||||
|
-- Check if third-party AI assistant is enabled
|
||||||
|
local ai_enabled = os.getenv "THIRD_PARTY_AI_ASSISTANT"
|
||||||
|
if ai_enabled and ai_enabled:lower() == "true" then return { import = "astrocommunity.completion.avante-nvim" } end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
---@type LazySpec[]
|
||||||
|
local modules = {
|
||||||
|
-- Base AstroCommunity plugin
|
||||||
|
"AstroNvim/astrocommunity",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Add framework-specific modules
|
||||||
|
local framework_modules = get_framework_modules()
|
||||||
|
for _, module in ipairs(framework_modules) do
|
||||||
|
table.insert(modules, module)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add AI modules if enabled
|
||||||
|
local ai_module = get_ai_modules()
|
||||||
|
if ai_module then
|
||||||
|
table.insert(modules, ai_module)
|
||||||
|
end
|
||||||
|
|
||||||
|
return modules
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
{
|
{
|
||||||
"AstroNvim/AstroNvim",
|
"AstroNvim/AstroNvim",
|
||||||
version = "5.3.4", -- Remove version tracking to elect for nightly AstroNvim
|
version = "5.3.12", -- Remove version tracking to elect for nightly AstroNvim
|
||||||
import = "astronvim.plugins",
|
import = "astronvim.plugins",
|
||||||
opts = { -- AstroNvim options must be set here with the `import` key
|
opts = { -- AstroNvim options must be set here with the `import` key
|
||||||
mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up
|
mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ return {
|
|||||||
-- disable lua_ls formatting capability if you want to use StyLua to format your lua code
|
-- disable lua_ls formatting capability if you want to use StyLua to format your lua code
|
||||||
-- "lua_ls",
|
-- "lua_ls",
|
||||||
"volar",
|
"volar",
|
||||||
|
"vtsls",
|
||||||
|
"ts_ls",
|
||||||
},
|
},
|
||||||
timeout_ms = 7000, -- default format timeout
|
timeout_ms = 7000, -- default format timeout
|
||||||
-- filter = function(client) -- fully override the default formatting function
|
-- filter = function(client) -- fully override the default formatting function
|
||||||
|
|||||||
+78
-16
@@ -1,27 +1,89 @@
|
|||||||
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
|
-- Configuration module for avante.nvim plugin with DeepSeek API support
|
||||||
|
-- Returns configuration only if THIRD_PARTY_AI_ASSISTANT environment variable is set
|
||||||
|
|
||||||
---@type LazySpec
|
-- Check for the required environment variable containing the API key
|
||||||
|
-- If the key is not set, returns an empty table and the plugin won't load
|
||||||
|
local ai_enabled = os.getenv "THIRD_PARTY_AI_ASSISTANT"
|
||||||
|
if not ai_enabled or ai_enabled:lower() ~= "true" then return {} end
|
||||||
|
|
||||||
|
-- Main plugin configuration object
|
||||||
|
---@type LazyPluginSpec[]
|
||||||
return {
|
return {
|
||||||
{ -- further customize the options set by the community
|
{
|
||||||
|
-- Plugin identifier in GitHub repository
|
||||||
"yetone/avante.nvim",
|
"yetone/avante.nvim",
|
||||||
version = "0.0.23",
|
-- Plugin version for compatibility assurance
|
||||||
---@type avante.Config
|
version = "0.0.27",
|
||||||
|
-- Plugin configuration options
|
||||||
|
-- Remove the type annotation if avante.Config is undefined
|
||||||
opts = {
|
opts = {
|
||||||
provider = "deepseek",
|
provider = "deepseek_safe",
|
||||||
auto_suggestions_provider = "deepseek",
|
|
||||||
-- mode = "legacy",
|
behaviour = {
|
||||||
-- behaviour = {
|
auto_approve_tool_permissions = true,
|
||||||
-- auto_apply_diff_after_generation = false,
|
},
|
||||||
-- auto_focus_on_diff_view = true,
|
|
||||||
-- },
|
vendors = {
|
||||||
providers = {
|
deepseek_safe = {
|
||||||
deepseek = {
|
|
||||||
__inherited_from = "openai",
|
__inherited_from = "openai",
|
||||||
api_key_name = "DEEPSEEK_API_KEY",
|
api_key_name = "DEEPSEEK_API_KEY",
|
||||||
endpoint = "https://api.deepseek.com",
|
endpoint = "https://api.deepseek.com",
|
||||||
model = "deepseek-coder",
|
model = "deepseek-chat",
|
||||||
|
timeout = 120000,
|
||||||
max_tokens = 8192,
|
max_tokens = 8192,
|
||||||
-- disable_tools = true,
|
extra_request_body = {
|
||||||
|
temperature = 0,
|
||||||
|
max_tokens = 8192,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- parse_curl_args = function(opts, code_opts)
|
||||||
|
-- local log_file = io.open("/tmp/avante_debug.log", "a")
|
||||||
|
--
|
||||||
|
-- -- Helper function to extract text from content
|
||||||
|
-- local function get_content_text(content)
|
||||||
|
-- if type(content) == "string" then
|
||||||
|
-- return content
|
||||||
|
-- elseif type(content) == "table" then
|
||||||
|
-- -- Content can be array of {type="text", text="..."}
|
||||||
|
-- if content.text then
|
||||||
|
-- return content.text
|
||||||
|
-- elseif content[1] and content[1].text then
|
||||||
|
-- return content[1].text
|
||||||
|
-- end
|
||||||
|
-- return vim.inspect(content) -- fallback
|
||||||
|
-- end
|
||||||
|
-- return ""
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- if log_file and code_opts.messages then
|
||||||
|
-- log_file:write "\n=== NEW REQUEST ===\n"
|
||||||
|
-- log_file:write(string.format("Total messages: %d\n", #code_opts.messages))
|
||||||
|
--
|
||||||
|
-- -- Check for duplicates
|
||||||
|
-- if #code_opts.messages >= 2 then
|
||||||
|
-- local last = code_opts.messages[#code_opts.messages]
|
||||||
|
-- local prev = code_opts.messages[#code_opts.messages - 1]
|
||||||
|
--
|
||||||
|
-- local last_text = get_content_text(last.content)
|
||||||
|
-- local prev_text = get_content_text(prev.content)
|
||||||
|
--
|
||||||
|
-- log_file:write(string.format("\nLast text: %s\n", last_text))
|
||||||
|
-- log_file:write(string.format("Prev text: %s\n", prev_text))
|
||||||
|
--
|
||||||
|
-- if last_text == prev_text and last_text ~= "" then
|
||||||
|
-- log_file:write "\n!!! DUPLICATE DETECTED !!!\n"
|
||||||
|
-- log_file:close()
|
||||||
|
-- vim.notify("Duplicate message detected! Aborting.", vim.log.levels.ERROR)
|
||||||
|
-- return nil
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- log_file:close()
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- local openai = require("avante.providers").openai
|
||||||
|
-- return openai.parse_curl_args(opts, code_opts)
|
||||||
|
-- end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
init.lua
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
-- Customize Mason
|
|
||||||
|
|
||||||
---@type LazySpec
|
|
||||||
return {
|
|
||||||
-- use mason-tool-installer for automatically installing Mason packages
|
|
||||||
{
|
|
||||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
||||||
-- overrides `require("mason-tool-installer").setup(...)`
|
|
||||||
opts = {
|
|
||||||
-- Make sure to use the names found in `:Mason`
|
|
||||||
ensure_installed = {
|
|
||||||
-- { "vue-language-server", version = "1.8.27" },
|
|
||||||
"black",
|
|
||||||
"python-lsp-server",
|
|
||||||
"mypy",
|
|
||||||
"pylint",
|
|
||||||
"flake8",
|
|
||||||
"pylama",
|
|
||||||
"bandit",
|
|
||||||
"pydocstyle",
|
|
||||||
"pyproject-flake8",
|
|
||||||
"pyproject-fmt",
|
|
||||||
"reorder-python-imports",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
-- Customize Mason
|
|
||||||
|
|
||||||
---@type LazySpec
|
|
||||||
return {
|
|
||||||
-- use mason-tool-installer for automatically installing Mason packages
|
|
||||||
{
|
|
||||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
||||||
-- overrides `require("mason-tool-installer").setup(...)`
|
|
||||||
opts = {
|
|
||||||
-- Make sure to use the names found in `:Mason`
|
|
||||||
ensure_installed = {
|
|
||||||
-- lspconfig
|
|
||||||
"eslint-lsp",
|
|
||||||
"stylelint-lsp",
|
|
||||||
"tailwindcss-language-server",
|
|
||||||
"typescript-language-server",
|
|
||||||
-- "vue-language-server",
|
|
||||||
{ "vue-language-server", version = "1.8.27" },
|
|
||||||
|
|
||||||
-- null_ls
|
|
||||||
"stylelint",
|
|
||||||
"prettier",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
|
|
||||||
|
|
||||||
-- This will run last in the setup process.
|
|
||||||
-- This is just pure lua so anything that doesn't
|
|
||||||
-- fit in the normal config locations above can go here
|
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
--- Mason package installation utilities for Neovim.
|
||||||
|
--- This module provides functions for installing Mason packages based on framework environment.
|
||||||
|
|
||||||
|
--- @alias FrameworkName "python"|"vue"|string
|
||||||
|
|
||||||
|
--- @class FrameworkTools
|
||||||
|
--- @field python string[] Python development tools and LSP servers including formatters, linters, and type checkers
|
||||||
|
--- @field vue string[] Vue.js development tools and LSP servers including JavaScript/TypeScript tools and CSS utilities
|
||||||
|
|
||||||
|
--- Framework-specific tool configurations
|
||||||
|
--- Maps framework names to their respective tool lists
|
||||||
|
--- @type FrameworkTools
|
||||||
|
local FRAMEWORK_TOOLS = {
|
||||||
|
python = {
|
||||||
|
"black",
|
||||||
|
"python-lsp-server",
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
"flake8",
|
||||||
|
"pylama",
|
||||||
|
"bandit",
|
||||||
|
"pydocstyle",
|
||||||
|
"pyproject-flake8",
|
||||||
|
"pyproject-fmt",
|
||||||
|
"reorder-python-imports",
|
||||||
|
},
|
||||||
|
vue = {
|
||||||
|
"eslint-lsp",
|
||||||
|
"stylelint-lsp",
|
||||||
|
"tailwindcss-language-server",
|
||||||
|
"typescript-language-server",
|
||||||
|
"stylelint",
|
||||||
|
"prettier",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Retrieves the appropriate tool set based on the current framework environment.
|
||||||
|
--- This function checks the FRAMEWORK environment variable and returns the corresponding
|
||||||
|
--- tool list from FRAMEWORK_TOOLS. If no framework is set or the framework is not recognized,
|
||||||
|
--- returns an empty table.
|
||||||
|
--- @return string[] tools List of tools to install for the detected framework, or empty table if no framework is set
|
||||||
|
local function get_framework_tools()
|
||||||
|
local current_framework = os.getenv "FRAMEWORK"
|
||||||
|
|
||||||
|
if current_framework then
|
||||||
|
local tools = FRAMEWORK_TOOLS[current_framework]
|
||||||
|
return tools or {}
|
||||||
|
else
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Validates if a package name is safe to install.
|
||||||
|
--- This function performs basic security validation to prevent command injection
|
||||||
|
--- and ensures package names follow expected patterns.
|
||||||
|
--- @param package_name string The package name to validate
|
||||||
|
--- @return boolean is_valid True if the package name is valid, false otherwise
|
||||||
|
local function is_valid_package_name(package_name)
|
||||||
|
-- Basic validation: package names should only contain alphanumeric characters, hyphens, and dots
|
||||||
|
-- This prevents command injection attacks
|
||||||
|
if type(package_name) ~= "string" or package_name == "" then return false end
|
||||||
|
|
||||||
|
-- Additional security: check for potentially dangerous patterns
|
||||||
|
local dangerous_patterns = {
|
||||||
|
"%.%.%/", -- Path traversal
|
||||||
|
"%;", -- Command separator
|
||||||
|
"%|", -- Pipe
|
||||||
|
"%&", -- Background process
|
||||||
|
"%`", -- Command substitution
|
||||||
|
"%$", -- Variable expansion
|
||||||
|
"%!", -- History expansion
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pattern in ipairs(dangerous_patterns) do
|
||||||
|
if string.match(package_name, pattern) then return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check for valid characters: alphanumeric, hyphen, dot, underscore
|
||||||
|
local valid_pattern = "^[%w%-%.%_]+$"
|
||||||
|
return string.match(package_name, valid_pattern) ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if Mason is available and ready for package installation.
|
||||||
|
--- @return boolean is_available True if Mason is available, false otherwise
|
||||||
|
local function is_mason_available()
|
||||||
|
local mason_ok, _ = pcall(require, "mason")
|
||||||
|
return mason_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Installs Mason packages based on the current framework environment.
|
||||||
|
--- This function retrieves the appropriate tool set and installs them one by one
|
||||||
|
--- to handle individual failures gracefully. Each package installation is wrapped
|
||||||
|
--- in a protected call to prevent one failure from stopping the entire process.
|
||||||
|
--- @return nil
|
||||||
|
function InstallMyMasonPackages()
|
||||||
|
-- Check if Mason is available first
|
||||||
|
if not is_mason_available() then
|
||||||
|
vim.notify("Mason is not available. Please install Mason first.", vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local packages = get_framework_tools()
|
||||||
|
|
||||||
|
if #packages > 0 then
|
||||||
|
local installed_count = 0
|
||||||
|
local failed_count = 0
|
||||||
|
|
||||||
|
-- Install packages one by one to handle individual failures
|
||||||
|
for _, package in ipairs(packages) do
|
||||||
|
-- Validate package name for security
|
||||||
|
if not is_valid_package_name(package) then
|
||||||
|
vim.notify("Skipping invalid package name: " .. package, vim.log.levels.WARN)
|
||||||
|
failed_count = failed_count + 1
|
||||||
|
else
|
||||||
|
local success, result = pcall(function() vim.cmd("MasonInstall " .. package) end)
|
||||||
|
|
||||||
|
if success then
|
||||||
|
installed_count = installed_count + 1
|
||||||
|
vim.notify("Successfully installed: " .. package, vim.log.levels.INFO)
|
||||||
|
else
|
||||||
|
failed_count = failed_count + 1
|
||||||
|
vim.notify("Failed to install " .. package .. ": " .. tostring(result), vim.log.levels.WARN)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Provide summary
|
||||||
|
if failed_count == 0 then
|
||||||
|
vim.notify(
|
||||||
|
"Framework-specific packages installation completed successfully. Installed: " .. installed_count .. " packages",
|
||||||
|
vim.log.levels.INFO
|
||||||
|
)
|
||||||
|
else
|
||||||
|
vim.notify(
|
||||||
|
"Framework-specific packages installation completed with "
|
||||||
|
.. failed_count
|
||||||
|
.. " failures. Successfully installed: "
|
||||||
|
.. installed_count
|
||||||
|
.. " packages",
|
||||||
|
vim.log.levels.WARN
|
||||||
|
)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
vim.notify("No framework detected or no packages to install", vim.log.levels.INFO)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Module exports
|
||||||
|
return {
|
||||||
|
FRAMEWORK_TOOLS = FRAMEWORK_TOOLS,
|
||||||
|
get_framework_tools = get_framework_tools,
|
||||||
|
InstallMyMasonPackages = InstallMyMasonPackages,
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
--- @meta
|
||||||
|
|
||||||
|
--- Framework-specific tool configurations and installation utilities for Neovim.
|
||||||
|
--- This module provides automatic installation of language servers and tools
|
||||||
|
--- based on the current development framework environment.
|
||||||
|
--- It reads the FRAMEWORK environment variable to determine which tools to install.
|
||||||
|
|
||||||
|
-- Import Mason utilities from separate module
|
||||||
|
local mason = require "polish.framework_mason_packages"
|
||||||
|
|
||||||
|
-- Create user command for Mason installation
|
||||||
|
vim.api.nvim_create_user_command(
|
||||||
|
"MasonInstallForFramework", -- Command name
|
||||||
|
mason.InstallMyMasonPackages, -- Function to call
|
||||||
|
{ nargs = 0 } -- Command takes no arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Module exports
|
||||||
|
return {
|
||||||
|
FRAMEWORK_TOOLS = mason.FRAMEWORK_TOOLS,
|
||||||
|
get_framework_tools = mason.get_framework_tools,
|
||||||
|
InstallMyMasonPackages = mason.InstallMyMasonPackages,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user