generated from ellisonleao/nvim-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: modularize and remove old dap config
details: - remove non-working dap config - move some code around - do not start a new terminal with each new `:e` on the same session
- Loading branch information
Showing
4 changed files
with
189 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
local api = vim.api | ||
local fs = vim.fs | ||
local base_handlers = require "powershell.handlers" | ||
|
||
local M = {} | ||
|
||
---@type powershell.config | ||
M.default_config = { | ||
capabilities = vim.lsp.protocol.make_client_capabilities(), | ||
bundle_path = "", | ||
init_options = vim.empty_dict() --[[@as table]], | ||
settings = vim.empty_dict() --[[@as table]], | ||
shell = "pwsh", | ||
handlers = base_handlers, | ||
root_dir = function(buf) | ||
local current_file_dir = fs.dirname(api.nvim_buf_get_name(buf)) | ||
return fs.dirname(fs.find({ ".git" }, { upward = true, path = current_file_dir })[1]) or current_file_dir | ||
end, | ||
} | ||
|
||
---@type powershell.config | ||
M.config = nil | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
local api = vim.api | ||
local util = require "powershell.util" | ||
|
||
local M = {} | ||
|
||
-- TODO: modify to allow multiple different seession_files | ||
local temp_path = vim.fn.stdpath "cache" | ||
local session_file_path = ("%s/powershell_es.temp_session.json"):format(temp_path) | ||
session_file_path = vim.fs.normalize(session_file_path) | ||
local log_file_path = ("%s/powershell_es.temp.log"):format(temp_path) | ||
log_file_path = vim.fs.normalize(log_file_path) | ||
vim.fn.delete(session_file_path) | ||
|
||
---@param bundle_path string | ||
---@return string[] | ||
local function make_args(bundle_path) | ||
local file = ("%s/PowerShellEditorServices/Start-EditorServices.ps1"):format(bundle_path) | ||
file = vim.fs.normalize(file) | ||
--stylua: ignore | ||
return { | ||
"-NoLogo", | ||
"-NoProfile", | ||
"-NonInteractive", | ||
"-File", file, | ||
"-HostName", "nvim", | ||
"-HostProfileId", "Neovim", | ||
"-HostVersion", "1.0.0", | ||
"-LogPath", log_file_path, | ||
-- TODO: make this configurable | ||
"-LogLevel", "Normal", | ||
"-BundledModulesPath", ("%s"):format(bundle_path), | ||
"-DebugServiceOnly", | ||
"-DebugServicePipeName", "${pipe}", | ||
-- TODO: wait for response on https://github.com/PowerShell/PowerShellEditorServices/issues/2164 | ||
-- "-EnableConsoleRepl", | ||
"-SessionDetailsPath", session_file_path, | ||
} | ||
end | ||
|
||
function M.setup() | ||
local dap = require "dap" | ||
local config = require("powershell.config").config | ||
|
||
-- TODO: this is broken on windows until https://github.com/mfussenegger/nvim-dap/issues/1230 | ||
dap.adapters.powershell_no_term = function(on_config) | ||
on_config { | ||
type = "pipe", | ||
pipe = "${pipe}", | ||
executable = { | ||
command = config.shell, | ||
args = make_args(config.bundle_path), | ||
detached = false, | ||
}, | ||
} | ||
end | ||
dap.configurations.ps1 = { | ||
{ | ||
name = "PowerShell: Launch Current File (no term)", | ||
type = "powershell_no_term", | ||
request = "launch", | ||
script = "${file}", | ||
}, | ||
} | ||
end | ||
|
||
return M |
Oops, something went wrong.