From 969aa6d3444f857c383b0e271febe087cd224349 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Fri, 23 Aug 2024 09:40:05 -0300 Subject: Feat: update --- lua/pi/animations.lua | 2 +- lua/pi/dap/configs/cpp.lua | 33 +++++++++++++++++++++++++ lua/pi/lsp/default.lua | 5 ++++ lua/pi/lsp/init.lua | 2 +- lua/pi/lsp/null-ls.lua | 1 + lua/pi/lsp/servers/clangd.lua | 21 ++++++++++++++++ lua/pi/lsp/servers/smarty_ls.lua | 25 +++++++++++++++++++ lua/pi/lsp/servers/vscode_smarty_langserver.lua | 25 ------------------- 8 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 lua/pi/dap/configs/cpp.lua create mode 100644 lua/pi/lsp/servers/clangd.lua create mode 100644 lua/pi/lsp/servers/smarty_ls.lua delete mode 100644 lua/pi/lsp/servers/vscode_smarty_langserver.lua (limited to 'lua/pi') diff --git a/lua/pi/animations.lua b/lua/pi/animations.lua index c0b7a6c..3ff711f 100644 --- a/lua/pi/animations.lua +++ b/lua/pi/animations.lua @@ -1,6 +1,6 @@ local redraw_buffer = function() local Animation = require "animation" - local fps = 45 -- frames per second + local fps = 15 -- frames per second local easing = require "animation.easing" local buffer = 0 diff --git a/lua/pi/dap/configs/cpp.lua b/lua/pi/dap/configs/cpp.lua new file mode 100644 index 0000000..d51d6bd --- /dev/null +++ b/lua/pi/dap/configs/cpp.lua @@ -0,0 +1,33 @@ +local dap = require("dap") + +dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + command = '~/.local/share/nvim/mason/packages/cpptools/extension/debugAdapters/bin/OpenDebugAD7', +} + +dap.configurations.cpp = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = 'Attach to gdbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'gdb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/gdb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + }, +} +dap.configurations.c = dap.configurations.cpp diff --git a/lua/pi/lsp/default.lua b/lua/pi/lsp/default.lua index e2517f0..8a47cbf 100644 --- a/lua/pi/lsp/default.lua +++ b/lua/pi/lsp/default.lua @@ -28,6 +28,11 @@ return { filetypes = {"smarty"}, root_dir = require("lspconfig.util").root_pattern("composer.json", ".git"), }, + clangd = { + enable = true, + filetypes = {"c", "cpp", "objc", "objcpp", "cuda", "proto" }, + root_dir = require("lspconfig.util").root_pattern("compile_commands.json", ".git"), + }, }, default_options = function (options) return vim.tbl_deep_extend("force", { diff --git a/lua/pi/lsp/init.lua b/lua/pi/lsp/init.lua index 17d73a1..64d09b7 100644 --- a/lua/pi/lsp/init.lua +++ b/lua/pi/lsp/init.lua @@ -3,7 +3,7 @@ return { ops = vim.tbl_deep_extend("force", require "pi.lsp.default", ops) local lspconfig = require "lspconfig" - + require('lspconfig.ui.windows').default_options.border = 'single' local mason_servers = {} for server, options in pairs(ops.servers) do if options.enable == true then diff --git a/lua/pi/lsp/null-ls.lua b/lua/pi/lsp/null-ls.lua index b105018..70693d9 100644 --- a/lua/pi/lsp/null-ls.lua +++ b/lua/pi/lsp/null-ls.lua @@ -38,6 +38,7 @@ null_ls.setup { end, }, null_ls.builtins.formatting.pint, + null_ls.builtins.formatting.clang_format, }, } diff --git a/lua/pi/lsp/servers/clangd.lua b/lua/pi/lsp/servers/clangd.lua new file mode 100644 index 0000000..87633cd --- /dev/null +++ b/lua/pi/lsp/servers/clangd.lua @@ -0,0 +1,21 @@ +local lsp_attach = require "pi.lsp.attach" +local lsp_flags = require "pi.lsp.flags" + +return function(ops) + local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + local config = { + on_attach = lsp_attach, + flags = lsp_flags, + capabilities = vim.tbl_deep_extend("force", capabilities, { + offsetEncoding = { "utf-16" }, + general = { + positionEncodings = { "utf-16" }, + }, + }), + } + if vim.fn.executable "clangd" == 1 then + config.cmd = { "clangd" } + end + + return vim.tbl_extend("force", config, ops) +end diff --git a/lua/pi/lsp/servers/smarty_ls.lua b/lua/pi/lsp/servers/smarty_ls.lua new file mode 100644 index 0000000..bf29082 --- /dev/null +++ b/lua/pi/lsp/servers/smarty_ls.lua @@ -0,0 +1,25 @@ +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 = { + css = { + validate = true + }, + smarty = { + pluginDirs = {} + }, + ["smarty_ls"] = { + checkOnSave = { + overrideCommand = { + "smarty-language-server", + "--stdio", + }, + }, + }, + }, + }, ops) +end diff --git a/lua/pi/lsp/servers/vscode_smarty_langserver.lua b/lua/pi/lsp/servers/vscode_smarty_langserver.lua deleted file mode 100644 index bf29082..0000000 --- a/lua/pi/lsp/servers/vscode_smarty_langserver.lua +++ /dev/null @@ -1,25 +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 = { - css = { - validate = true - }, - smarty = { - pluginDirs = {} - }, - ["smarty_ls"] = { - checkOnSave = { - overrideCommand = { - "smarty-language-server", - "--stdio", - }, - }, - }, - }, - }, ops) -end -- cgit v1.2.3