fix(neovim): use getnixpath util for nvim-dap and lsp, move polish
This moves polish.lua to `lua/`, creates a util.lua file to be loaded before lazy.nvim so we can use the `getnixpath` util everywhere, and replaces in polish.lua and lsp.lua the template strings for substitution with a `getnixpath` equivalent
This commit is contained in:
parent
ef337e45c0
commit
a2ff5d1b6a
|
@ -153,15 +153,7 @@ in
|
||||||
|
|
||||||
substituteInPlace $out \
|
substituteInPlace $out \
|
||||||
--replace-fail "{hostname}" "${config.programs.neovim.nixd.hostname}" \
|
--replace-fail "{hostname}" "${config.programs.neovim.nixd.hostname}" \
|
||||||
--replace-fail "{location}" "${config.programs.neovim.nixd.location}" \
|
--replace-fail "{location}" "${config.programs.neovim.nixd.location}"
|
||||||
--replace-fail "{pkgs.vue-language-server}" "${pkgs.vue-language-server}"
|
|
||||||
'';
|
|
||||||
|
|
||||||
xdg.configFile."nvim/lua/polish.lua".source = pkgs.runCommand "polish.lua" { } ''
|
|
||||||
cp ${./polish.lua} $out
|
|
||||||
|
|
||||||
substituteInPlace $out \
|
|
||||||
--replace-fail "{pkgs.vscode-extensions.ms-vscode.cpptools}" "${pkgs.vscode-extensions.ms-vscode.cpptools}" \
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,21 @@
|
||||||
local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
|
local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
|
||||||
if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then
|
if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
|
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable",
|
||||||
|
lazypath })
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
-- validate that lazy is available
|
-- validate that lazy is available
|
||||||
if not pcall(require, "lazy") then
|
if not pcall(require, "lazy") then
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
|
vim.api.nvim_echo(
|
||||||
vim.fn.getchar()
|
{ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } },
|
||||||
vim.cmd.quit()
|
true, {})
|
||||||
|
vim.fn.getchar()
|
||||||
|
vim.cmd.quit()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "util"
|
||||||
require "lazy_setup"
|
require "lazy_setup"
|
||||||
require "polish"
|
require "polish"
|
||||||
|
|
|
@ -104,7 +104,8 @@ return {
|
||||||
globalPlugins = {
|
globalPlugins = {
|
||||||
{
|
{
|
||||||
name = "@vue/typescript-plugin",
|
name = "@vue/typescript-plugin",
|
||||||
location = "{pkgs.vue-language-server}/lib/node_modules/@vue/language-server",
|
location = vim.fn.getnixpath "vue-language-server"
|
||||||
|
.. "/lib/node_modules/@vue/language-server",
|
||||||
languages = { "vue" },
|
languages = { "vue" },
|
||||||
configNamespace = "typescript",
|
configNamespace = "typescript",
|
||||||
enableForWorkspaceTypeScriptVersions = true,
|
enableForWorkspaceTypeScriptVersions = true,
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
---@type LazySpec
|
||||||
|
return {
|
||||||
|
"mfussenegger/nvim-dap",
|
||||||
|
config = function()
|
||||||
|
local dap = require "dap"
|
||||||
|
|
||||||
|
---@type dap.Adapter
|
||||||
|
dap.adapters.codelldb = {
|
||||||
|
port = "${port}",
|
||||||
|
type = "server",
|
||||||
|
executable = {
|
||||||
|
command = "codelldb",
|
||||||
|
args = { "--port", "${port}" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type dap.Configuration[]
|
||||||
|
dap.configurations.rust = {
|
||||||
|
{
|
||||||
|
name = "Launch file",
|
||||||
|
type = "codelldb",
|
||||||
|
request = "launch",
|
||||||
|
program = function()
|
||||||
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||||
|
end,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type dap.Adapter
|
||||||
|
dap.adapters.cppdbg = {
|
||||||
|
id = "cppdbg",
|
||||||
|
type = "executable",
|
||||||
|
command = vim.fn.getnixpath "vscode-extensions.ms-vscode.cpptools"
|
||||||
|
.. "/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7",
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type dap.Configuration[]
|
||||||
|
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
|
||||||
|
|
||||||
|
---@type dap.Adapter
|
||||||
|
dap.adapters.godot = {
|
||||||
|
type = "server",
|
||||||
|
host = "127.0.0.1",
|
||||||
|
port = 6006,
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type dap.Configuration[]
|
||||||
|
dap.configurations.gdscript = {
|
||||||
|
{
|
||||||
|
name = "Launch scene",
|
||||||
|
type = "godot",
|
||||||
|
request = "launch",
|
||||||
|
project = "${workspaceFolder}",
|
||||||
|
scene = "current",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
|
@ -7,12 +7,10 @@ return {
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{
|
{
|
||||||
"tris203/rzls.nvim",
|
"tris203/rzls.nvim",
|
||||||
config = function()
|
opts = {
|
||||||
---@diagnostic disable-next-line: missing-fields
|
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
||||||
require("rzls").setup {
|
path = vim.fn.getnixpath "rzls" .. "/bin/rzls",
|
||||||
path = vim.fn.getnixpath "rzls" .. "/bin/rzls",
|
},
|
||||||
}
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
|
|
16
modules/home-manager/programs/neovim/lua/polish.lua
Normal file
16
modules/home-manager/programs/neovim/lua/polish.lua
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
-- This will run last in the setup process and is a good place to configure
|
||||||
|
-- things like custom filetypes. This just pure lua so anything that doesn't
|
||||||
|
-- fit in the normal config locations above can go here
|
||||||
|
|
||||||
|
-- Set up custom filetypes
|
||||||
|
vim.filetype.add {
|
||||||
|
extension = {
|
||||||
|
foo = "fooscript",
|
||||||
|
},
|
||||||
|
filename = {
|
||||||
|
["Foofile"] = "fooscript",
|
||||||
|
},
|
||||||
|
pattern = {
|
||||||
|
["~/%.config/foo/.*"] = "fooscript",
|
||||||
|
},
|
||||||
|
}
|
65
modules/home-manager/programs/neovim/lua/util.lua
Normal file
65
modules/home-manager/programs/neovim/lua/util.lua
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
--- Define PackageOutput
|
||||||
|
--- @enum PackageOutput
|
||||||
|
local PACKAGEOUTPUT = {
|
||||||
|
out = 0,
|
||||||
|
lib = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Get the store path of a package
|
||||||
|
--- @param packagename NixSearchExceptions | string
|
||||||
|
--- @param packageoutput PackageOutput?
|
||||||
|
--- @return string | nil
|
||||||
|
vim.fn.getnixpath = function(packagename, packageoutput)
|
||||||
|
---@enum (key) NixSearchExceptions
|
||||||
|
local exceptions = {}
|
||||||
|
|
||||||
|
return vim.split(
|
||||||
|
vim.api.nvim_cmd(
|
||||||
|
vim.api.nvim_parse_cmd(
|
||||||
|
string.format(
|
||||||
|
"silent !NIXPKGS_ALLOW_UNFREE=1 nix eval --raw --expr 'with import <nixpkgs> { }; (%s).%s' --impure",
|
||||||
|
exceptions[packagename] or packagename,
|
||||||
|
(packageoutput == PACKAGEOUTPUT.out or packageoutput == nil) and "outPath"
|
||||||
|
or string.format("lib.getLib %s", packagename)
|
||||||
|
),
|
||||||
|
{}
|
||||||
|
) --[[@as vim.api.keyset.cmd]],
|
||||||
|
{
|
||||||
|
output = true,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
"\n"
|
||||||
|
)[3]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Helper function to allow me to run commands grabbed
|
||||||
|
--- by the current selection.
|
||||||
|
--- @param isLua boolean
|
||||||
|
--- @return string
|
||||||
|
vim.fn.runcmdonmark = function(isLua)
|
||||||
|
local beginRow, beginCol = unpack(vim.api.nvim_buf_get_mark(0, "<"))
|
||||||
|
local endRow, endCol = unpack(vim.api.nvim_buf_get_mark(0, ">"))
|
||||||
|
|
||||||
|
if beginRow == nil or beginCol == nil or endRow == nil or endCol == nil then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local text = table.concat(
|
||||||
|
vim.tbl_map(function(incoming)
|
||||||
|
return vim.trim(incoming)
|
||||||
|
end, vim.api.nvim_buf_get_text(0, beginRow - 1, beginCol, endRow - 1, endCol + 1, {})),
|
||||||
|
" "
|
||||||
|
)
|
||||||
|
|
||||||
|
vim.notify("Running expression: " .. text, vim.log.levels.INFO)
|
||||||
|
|
||||||
|
return vim.api.nvim_cmd(
|
||||||
|
vim.api.nvim_parse_cmd((isLua == true and ":lua " or "") .. text, {}) --[[@as vim.api.keyset.cmd]],
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Register the function as a command as well, to facilitate things.
|
||||||
|
vim.api.nvim_create_user_command("RunCmdOnMark", function(opts)
|
||||||
|
vim.fn.runcmdonmark((opts.args == "v:false" or opts.args == "false") and false or true)
|
||||||
|
end, { range = true, nargs = "?" })
|
|
@ -1,162 +0,0 @@
|
||||||
-- This will run last in the setup process and is a good place to configure
|
|
||||||
-- things like custom filetypes. This just pure lua so anything that doesn't
|
|
||||||
-- fit in the normal config locations above can go here
|
|
||||||
|
|
||||||
-- Set up custom filetypes
|
|
||||||
vim.filetype.add {
|
|
||||||
extension = {
|
|
||||||
foo = "fooscript",
|
|
||||||
},
|
|
||||||
filename = {
|
|
||||||
["Foofile"] = "fooscript",
|
|
||||||
},
|
|
||||||
pattern = {
|
|
||||||
["~/%.config/foo/.*"] = "fooscript",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Define PackageOutput
|
|
||||||
--- @enum PackageOutput
|
|
||||||
local PACKAGEOUTPUT = {
|
|
||||||
out = 0,
|
|
||||||
lib = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Get the store path of a package
|
|
||||||
--- @param packagename NixSearchExceptions | string
|
|
||||||
--- @param packageoutput PackageOutput?
|
|
||||||
--- @return string | nil
|
|
||||||
vim.fn.getnixpath = function(packagename, packageoutput)
|
|
||||||
---@enum (key) NixSearchExceptions
|
|
||||||
local exceptions = {}
|
|
||||||
|
|
||||||
return vim.split(
|
|
||||||
vim.api.nvim_cmd(
|
|
||||||
vim.api.nvim_parse_cmd(
|
|
||||||
string.format(
|
|
||||||
"silent !nix eval --raw --expr 'with import <nixpkgs> { }; (%s).%s' --impure",
|
|
||||||
exceptions[packagename] or packagename,
|
|
||||||
(packageoutput == PACKAGEOUTPUT.out or packageoutput == nil) and "outPath"
|
|
||||||
or string.format("lib.getLib %s", packagename)
|
|
||||||
),
|
|
||||||
{}
|
|
||||||
) --[[@as vim.api.keyset.cmd]],
|
|
||||||
{
|
|
||||||
output = true,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"\n"
|
|
||||||
)[3]
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Helper function to allow me to run commands grabbed
|
|
||||||
--- by the current selection.
|
|
||||||
--- @param isLua boolean
|
|
||||||
--- @return string
|
|
||||||
vim.fn.runcmdonmark = function(isLua)
|
|
||||||
local beginRow, beginCol = unpack(vim.api.nvim_buf_get_mark(0, "<"))
|
|
||||||
local endRow, endCol = unpack(vim.api.nvim_buf_get_mark(0, ">"))
|
|
||||||
|
|
||||||
if beginRow == nil or beginCol == nil or endRow == nil or endCol == nil then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
local text = table.concat(
|
|
||||||
vim.tbl_map(function(incoming)
|
|
||||||
return vim.trim(incoming)
|
|
||||||
end, vim.api.nvim_buf_get_text(0, beginRow - 1, beginCol, endRow - 1, endCol + 1, {})),
|
|
||||||
" "
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.notify("Running expression: " .. text, vim.log.levels.INFO)
|
|
||||||
|
|
||||||
return vim.api.nvim_cmd(
|
|
||||||
vim.api.nvim_parse_cmd((isLua == true and ":lua " or "") .. text, {}) --[[@as vim.api.keyset.cmd]],
|
|
||||||
{}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Register the function as a command as well, to facilitate things.
|
|
||||||
vim.api.nvim_create_user_command("RunCmdOnMark", function(opts)
|
|
||||||
vim.fn.runcmdonmark((opts.args == "v:false" or opts.args == "false") and false or true)
|
|
||||||
end, { range = true, nargs = "?" })
|
|
||||||
|
|
||||||
local dap = require "dap"
|
|
||||||
|
|
||||||
---@type dap.Adapter
|
|
||||||
dap.adapters.codelldb = {
|
|
||||||
port = "${port}",
|
|
||||||
type = "server",
|
|
||||||
executable = {
|
|
||||||
command = "codelldb",
|
|
||||||
args = { "--port", "${port}" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@type dap.Adapter
|
|
||||||
dap.adapters.cppdbg = {
|
|
||||||
id = "cppdbg",
|
|
||||||
type = "executable",
|
|
||||||
command =
|
|
||||||
"{pkgs.vscode-extensions.ms-vscode.cpptools}/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7",
|
|
||||||
}
|
|
||||||
|
|
||||||
---@type dap.Adapter
|
|
||||||
dap.adapters.godot = {
|
|
||||||
type = "server",
|
|
||||||
host = "127.0.0.1",
|
|
||||||
port = 6006,
|
|
||||||
}
|
|
||||||
|
|
||||||
---@type dap.Configuration[]
|
|
||||||
dap.configurations.rust = {
|
|
||||||
{
|
|
||||||
name = "Launch file",
|
|
||||||
type = "codelldb",
|
|
||||||
request = "launch",
|
|
||||||
program = function()
|
|
||||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
|
||||||
end,
|
|
||||||
cwd = "${workspaceFolder}",
|
|
||||||
stopOnEntry = false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@type dap.Configuration[]
|
|
||||||
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
|
|
||||||
|
|
||||||
---@type dap.Configuration[]
|
|
||||||
dap.configurations.gdscript = {
|
|
||||||
{
|
|
||||||
name = "Launch scene",
|
|
||||||
type = "godot",
|
|
||||||
request = "launch",
|
|
||||||
project = "${workspaceFolder}",
|
|
||||||
scene = "current",
|
|
||||||
},
|
|
||||||
}
|
|
Loading…
Reference in a new issue