From f032fb9e2fadaaec6f71aaf45ed1d94128ea45cd Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Thu, 3 Oct 2024 11:41:10 -0300 Subject: feat: add rust tools --- lua/pi/completition/init.lua | 74 ++++++++++++++++++------------------ lua/pi/dap/configs/rust.lua | 57 --------------------------- lua/pi/dap/configs/rust.old | 57 +++++++++++++++++++++++++++ lua/pi/dap/init.lua | 8 ++-- lua/pi/lsp/default.lua | 2 +- lua/pi/lsp/servers/rust_analyzer.lua | 24 ------------ lua/pi/lsp/servers/rust_analyzer.old | 24 ++++++++++++ 7 files changed, 123 insertions(+), 123 deletions(-) delete mode 100644 lua/pi/dap/configs/rust.lua create mode 100644 lua/pi/dap/configs/rust.old delete mode 100644 lua/pi/lsp/servers/rust_analyzer.lua create mode 100644 lua/pi/lsp/servers/rust_analyzer.old (limited to 'lua/pi') diff --git a/lua/pi/completition/init.lua b/lua/pi/completition/init.lua index 418c6d2..9ac1216 100644 --- a/lua/pi/completition/init.lua +++ b/lua/pi/completition/init.lua @@ -55,28 +55,30 @@ cmp.setup { [""] = cmp.mapping.complete(), }, sources = { - { name = "dictionary", keyword_length = 2}, + { name = "dictionary", keyword_length = 2 }, { name = "nvim_lua" }, { name = "nvim_lsp" }, { name = "path" }, { name = "luasnip" }, { name = "copilot" }, - {name = "codeium"}, + { name = "codeium" }, -- { name = 'cmp_ai' }, - { name = 'html-css', - option = { - max_count = {}, -- not ready yet - enable_on = { - "html", - "css" - }, -- set the file types you want the plugin to work on - file_extensions = { "css", "sass", "less" }, -- set the local filetypes from which you want to derive classes - style_sheets = { - -- example of remote styles, only css no js for now - "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css", - "https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css", - } - } + { + name = "html-css", + option = { + spa = { + enable = false, -- SPA mode is disabled by default + entry_file = "index.html", -- if entry_file is omitted, it defaults to index.html in root dir + }, + max_count = {}, -- not ready yet + enable_on = { "html", "css" }, -- set the file types you want the plugin to work on + file_extensions = { "css", "sass", "less" }, -- set the local filetypes from which you want to derive classes + style_sheets = { + -- example of remote styles, only css no js for now + "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css", + "https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css", + }, + }, }, { name = "buffer", @@ -104,12 +106,12 @@ cmp.setup { }, formatting = { - format = function (entry, vim_item) + format = function(entry, vim_item) if entry.source.name == "html-css" then - vim_item.menu = entry.completion_item.menu + source_mapping["html-css"] = "[" .. entry.completion_item.provider .. "]" or "[html-css]" end local KIND_ICONS = { - Tailwind = '󰹞󰹞󰹞󰹞󰹞󰹞󰹞󰹞', + Tailwind = "󰹞󰹞󰹞󰹞󰹞󰹞󰹞󰹞", Copilot = "", Ollama = "", Text = "󰉿", @@ -140,20 +142,20 @@ cmp.setup { TypeParameter = "󰜅", OpenAI = "", TinyLlama = "󱝊", - LlamaCPP = "" + LlamaCPP = "", } - if vim_item.kind == 'Color' and entry.completion_item.documentation then + if vim_item.kind == "Color" and entry.completion_item.documentation then local _, _, r, g, b = - ---@diagnostic disable-next-line: param-type-mismatch - string.find(entry.completion_item.documentation, '^rgb%((%d+), (%d+), (%d+)') + ---@diagnostic disable-next-line: param-type-mismatch + string.find(entry.completion_item.documentation, "^rgb%((%d+), (%d+), (%d+)") if r and g and b then - local color = string.format('%02x', r) .. string.format('%02x', g) .. string.format('%02x', b) - local group = 'Tw_' .. color + local color = string.format("%02x", r) .. string.format("%02x", g) .. string.format("%02x", b) + local group = "Tw_" .. color - if vim.api.nvim_call_function('hlID', { group }) < 1 then - vim.api.nvim_command('highlight' .. ' ' .. group .. ' ' .. 'guifg=#' .. color) + if vim.api.nvim_call_function("hlID", { group }) < 1 then + vim.api.nvim_command("highlight" .. " " .. group .. " " .. "guifg=#" .. color) end vim_item.kind = KIND_ICONS.Tailwind @@ -165,18 +167,16 @@ cmp.setup { vim_item.kind = KIND_ICONS[vim_item.kind] or vim_item.kind -- Add maxwidth and ellipsis_char in the middle - local maxwidth = 20 - local ellipsis_char = '...' + local maxwidth = 50 + local ellipsis_char = "..." if #vim_item.abbr > maxwidth then local half_width = math.floor((maxwidth - #ellipsis_char) / 2) - vim_item.abbr = string.sub( - vim_item.abbr, - 1, - half_width - ) .. ellipsis_char .. string.sub(vim_item.abbr, -half_width) + vim_item.abbr = string.sub(vim_item.abbr, 1, half_width) + .. ellipsis_char + .. string.sub(vim_item.abbr, -half_width) end return vim_item - end + end, }, sorting = { @@ -198,8 +198,8 @@ vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#3426C3" }) vim.api.nvim_set_hl(0, "CmpItemKindCodeium", { fg = "#2ACDBA" }) vim.api.nvim_set_hl(0, "CmpItemKindOllama", { fg = "#FDFEFF" }) vim.api.nvim_set_hl(0, "CmpItemKindOpenAI", { fg = "#080808" }) -vim.api.nvim_set_hl(0, "CmpItemKindTinyLlama", { fg = "#DF468C"}) -vim.api.nvim_set_hl(0, "CmpItemKindLlamaCPP", { fg = "#FF8235"}) +vim.api.nvim_set_hl(0, "CmpItemKindTinyLlama", { fg = "#DF468C" }) +vim.api.nvim_set_hl(0, "CmpItemKindLlamaCPP", { fg = "#FF8235" }) -- Set configuration for specific filetype. cmp.setup.filetype("gitcommit", { diff --git a/lua/pi/dap/configs/rust.lua b/lua/pi/dap/configs/rust.lua deleted file mode 100644 index 9ca976f..0000000 --- a/lua/pi/dap/configs/rust.lua +++ /dev/null @@ -1,57 +0,0 @@ -local dap = require("dap") - -local rust_adapter = nil -local rust_adapters = { "lldb-vscode", "codelldb" } -for _, adapter in pairs(rust_adapters) do - if vim.fn.executable(adapter) then - rust_adapter = adapter - end -end - -if rust_adapter ~= nil then - dap.adapters.lldb = { - type = "executable", - command = rust_adapter, - name = "lldb", - } - - dap.configurations.rust = { - { - name = "launch", - type = "lldb", - request = "launch", - program = function() - local dir = vim.fn.getcwd() - return dir .. "/target/debug/" .. vim.fs.basename(dir) - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - args = function() - local resp = vim.fn.input "Arguments: " - if resp == "" then - return {} - end - - return vim.fn.split(resp, " ") - end, - }, - { - name = "custom", - type = "lldb", - request = "launch", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - args = function() - local resp = vim.fn.input "Arguments: " - if resp == "" then - return {} - end - - return vim.fn.split(resp, " ") - end, - }, - } -end diff --git a/lua/pi/dap/configs/rust.old b/lua/pi/dap/configs/rust.old new file mode 100644 index 0000000..9ca976f --- /dev/null +++ b/lua/pi/dap/configs/rust.old @@ -0,0 +1,57 @@ +local dap = require("dap") + +local rust_adapter = nil +local rust_adapters = { "lldb-vscode", "codelldb" } +for _, adapter in pairs(rust_adapters) do + if vim.fn.executable(adapter) then + rust_adapter = adapter + end +end + +if rust_adapter ~= nil then + dap.adapters.lldb = { + type = "executable", + command = rust_adapter, + name = "lldb", + } + + dap.configurations.rust = { + { + name = "launch", + type = "lldb", + request = "launch", + program = function() + local dir = vim.fn.getcwd() + return dir .. "/target/debug/" .. vim.fs.basename(dir) + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local resp = vim.fn.input "Arguments: " + if resp == "" then + return {} + end + + return vim.fn.split(resp, " ") + end, + }, + { + name = "custom", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local resp = vim.fn.input "Arguments: " + if resp == "" then + return {} + end + + return vim.fn.split(resp, " ") + end, + }, + } +end diff --git a/lua/pi/dap/init.lua b/lua/pi/dap/init.lua index 327dedf..97084fd 100644 --- a/lua/pi/dap/init.lua +++ b/lua/pi/dap/init.lua @@ -10,11 +10,11 @@ for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/pi/dap/configs/*.lua end -- Signs -vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define("DapStopped", { text = "▶", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapBreakpointRejected", { text = "🚫", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapBreakpointCondition", { text = "❓", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapLogPoint", { text = "💬", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpointRejected", { text = "", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpointCondition", { text = "", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapLogPoint", { text = "󰍢", texthl = "", linehl = "", numhl = "" }) -- UI structure dapui.setup { diff --git a/lua/pi/lsp/default.lua b/lua/pi/lsp/default.lua index b2be73e..b2020db 100644 --- a/lua/pi/lsp/default.lua +++ b/lua/pi/lsp/default.lua @@ -11,7 +11,7 @@ return { lua_ls = { enable = true, neodev = true }, -- nil_ls = { enable = true }, phpactor = {enable = true }, - rust_analyzer = { enable = true }, + -- rust_analyzer = { enable = true }, svelte = { enable = true }, tailwindcss = { enable = true, filetypes = {"blade", "html", "svelte"} }, ts_ls = { enable = true }, diff --git a/lua/pi/lsp/servers/rust_analyzer.lua b/lua/pi/lsp/servers/rust_analyzer.lua deleted file mode 100644 index 8999ef8..0000000 --- a/lua/pi/lsp/servers/rust_analyzer.lua +++ /dev/null @@ -1,24 +0,0 @@ -local lsp_attach = require "pi.lsp.attach" -local lsp_flags = require "pi.lsp.flags" - -return function(ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["rust-analyzer"] = { - checkOnSave = { - allFeatures = true, - overrideCommand = { - "cargo", - "clippy", - "--workspace", - "--message-format=json", - "--all-targets", - "--all-features", - }, - }, - }, - }, - }, ops) -end diff --git a/lua/pi/lsp/servers/rust_analyzer.old b/lua/pi/lsp/servers/rust_analyzer.old new file mode 100644 index 0000000..8999ef8 --- /dev/null +++ b/lua/pi/lsp/servers/rust_analyzer.old @@ -0,0 +1,24 @@ +local lsp_attach = require "pi.lsp.attach" +local lsp_flags = require "pi.lsp.flags" + +return function(ops) + return vim.tbl_extend("force", { + on_attach = lsp_attach, + flags = lsp_flags, + settings = { + ["rust-analyzer"] = { + checkOnSave = { + allFeatures = true, + overrideCommand = { + "cargo", + "clippy", + "--workspace", + "--message-format=json", + "--all-targets", + "--all-features", + }, + }, + }, + }, + }, ops) +end -- cgit v1.2.3