commit 266ff9eee36847791af2a844752faf1e53866ae4
parent 07bc6a1c9c4bbed5fa01f64fd77036e5c6a20e80
Author: Tomas Nemec <owl@gtms.dev>
Date: Thu, 17 Apr 2025 06:48:00 +0200
update
Diffstat:
4 files changed, 73 insertions(+), 83 deletions(-)
diff --git a/after/ftplugin/java.lua b/after/ftplugin/java.lua
@@ -6,15 +6,16 @@ local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local root_dir = vim.fs.root(0, { ".git", "pom.xml", "mvnw", "gradlew" })
local bundles = {
- vim.fn.glob(vim.env.MASON .. "/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar",
- true)
+ -- vim.env.MASON .. "/share/java-debug-adapter/com.microsoft.java.test.plugin.jar",
+ vim.env.MASON .. "/share/java-test/com.microsoft.java.test.plugin.jar"
}
-vim.list_extend(bundles,
- vim.split(vim.fn.glob(vim.env.MASON .. "/packages/java-test/extension/server/*.jar", true), "\n"))
-
+-- vim.list_extend(bundles,
+-- vim.split(vim.fn.glob(vim.env.MASON .. "/share/java-debug-adapter/*.jar", true), "\n"))
+-- vim.list_extend(bundles,
+-- vim.split(vim.fn.glob(vim.env.MASON .. "/share/java-test/com.microsoft.java.test.plugin.jar", true), "\n"))
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
local config = {
- -- The command that starts the language server
+ -- The command that starts te language server
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
cmd = {
@@ -35,17 +36,17 @@ local config = {
-- repository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar
"-javaagent:" ..
vim.env.XDG_DATA_HOME ..
- "/containers/storage/volumes/maven/_data/repository/org/projectlombok/lombok/1.18.34/lombok-1.18.34.jar",
+ "/maven/repository/org/projectlombok/lombok/1.18.34/lombok-1.18.34.jar",
-- 💀
- '-jar', vim.env.MASON .. '/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar',
+ '-jar', vim.fn.glob(vim.env.MASON .. '/share/jdtls/plugins/org.eclipse.equinox.launcher_*.jar', true),
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
-- Must point to the Change this to
-- eclipse.jdt.ls installation the actual version
-- 💀
- '-configuration', vim.env.MASON .. '/packages/jdtls/config_linux',
+ '-configuration', vim.env.MASON .. '/share/jdtls/config',
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
-- Must point to the Change to one of `linux`, `win` or `mac`
-- eclipse.jdt.ls installation Depending on your system.
diff --git a/after/ftplugin/zsh.lua b/after/ftplugin/zsh.lua
@@ -19,7 +19,7 @@ end
vim.keymap.set('n', '<leader>ar', function()
local temp_prg = set.makeprg
local temp_efm = set.efm
- set.makeprg = [[./%]]
+ set.makeprg = [[zsh %:S]]
set.efm = [[%f:%.%#:%l:\ %m,%f:%l:\ %m,%-G%.%#]]
vim.cmd.make()
set.makeprg = temp_prg
diff --git a/after/plugin/dap.lua b/after/plugin/dap.lua
@@ -148,7 +148,10 @@ table.insert(dap.configurations.dart, {
local has_vscode, vscode = pcall(require, 'dap-vscode-js')
if has_vscode then
-- The VSCode Debugger requires a special setup
- vscode.setup({ adapters = { 'pwa-node', 'pwa-chrome' } })
+ vscode.setup({
+ debugger_path = vim.fn.stdpath("data") .. "/site/pack/paqs/opt/vscode-js-debug",
+ adapters = { 'pwa-node', 'pwa-chrome' }
+ })
table.insert(dap.configurations.dart, {
--
diff --git a/lua/tms/p/terminal.lua b/lua/tms/p/terminal.lua
@@ -1,100 +1,85 @@
-local winh = nil
-local bufh = nil
-local chan = nil
-local last_command = nil
-
--- Returns a bool to show if the terminal window exists
-local function win_is_open()
- return winh ~= nil and vim.api.nvim_win_is_valid(winh)
-end
-
--- returns a bool to show if the buf exists
-local function buf_is_valid()
- return bufh ~= nil and vim.api.nvim_buf_is_valid(bufh)
-end
+--- Dispatchers for LSP message types.
+--- @class (private) State
+--- @field win integer?
+--- @field last_win integer?
+--- @field buf integer
+--- @field chan integer
+--- @field last_command string?
+local State = {
+}
--- Creates the terminal window and return the user to the window where the call was made
-local function create_window()
- local curr = vim.api.nvim_get_current_win()
- vim.cmd('botright 12split')
- winh = vim.api.nvim_get_current_win()
- vim.api.nvim_set_current_win(curr)
+function State:is_open()
+ return self.win and vim.api.nvim_win_is_valid(self.win)
end
--- Creates the terminal buffer and starts the terminal
-local function create_buffer()
- local curr = vim.api.nvim_get_current_win()
- bufh = vim.api.nvim_create_buf(false, true)
- vim.api.nvim_win_set_buf(winh, bufh)
- vim.api.nvim_set_current_win(winh)
- vim.cmd.term()
- vim.cmd.normal('G')
- vim.api.nvim_buf_set_name(bufh, 'terminal')
- chan = vim.b.terminal_job_id
- vim.api.nvim_set_current_win(curr)
+function State:is_valid()
+ return self.buf and vim.api.nvim_buf_is_valid(self.buf) and self.chan
end
local M = {}
--- Toggles the terminal window.
---
--- If the window doesn't exist it is created. If it already exists, it is closed
--- If the buffer doesn't exist is is created and set as the active buffer in the terminal window
--- If either the window of buffer were created, the window buffer is set to the terminal buffer
M.toggle = function()
- local link_buf = false
- if win_is_open() then
- vim.api.nvim_win_close(winh, true)
- winh = nil
- else
- create_window()
- link_buf = true
- end
- if buf_is_valid() == false then
- create_buffer()
- link_buf = true
+ State.last_win = vim.api.nvim_get_current_win()
+
+ if State:is_open() then
+ vim.api.nvim_win_close(State.win, true)
+ State.win = nil
+ return
end
- if link_buf then
- vim.api.nvim_win_set_buf(winh, bufh)
+ if not State:is_valid() then
+ State.buf = vim.api.nvim_create_buf(false, true)
end
+
+ State.win = vim.api.nvim_open_win(State.buf, false, { split = 'below', height = 12 })
+
+ -- NOT WORKING
+ -- print(vim.api.nvim_open_term(State.buf, {}))
+
+ vim.api.nvim_set_current_win(State.win)
+ vim.cmd.term()
+ State.chan = vim.opt.channel:get()
+ vim.api.nvim_buf_set_name(State.buf, 'terminal')
+ vim.cmd.normal('G')
+ vim.cmd.wincmd('w')
end
-- Closes the window and deletes the buffer. This entirely resets the term state
M.exit = function()
- if win_is_open() then
- vim.api.nvim_win_close(winh, true)
- winh = nil
+ if State:is_open() then
+ vim.api.nvim_win_close(State.win, true)
+ State.win = nil
end
- if buf_is_valid() then
- vim.api.nvim_buf_delete(bufh, { force = true })
- bufh = nil
+
+ if State:is_valid() then
+ vim.api.nvim_buf_delete(State.buf, { force = true })
end
- chan = nil
+
+ State.buf = nil
+ State.chan = nil
end
-- Takes a command as a string and runs it in the terminal buffer. If the window is closed, it will be toggled
+---@param cmd string
M.run = function(cmd)
- -- print(cmd)
- if win_is_open() == false or chan == nil then
+ if not State:is_open() and not State:is_valid() then
M.toggle()
- end
-
- if last_command ~= nil then
+ elseif State.last_command then
-- Send <C-c> to make sure any on-going commands like log tails are stopped before running the new command
- vim.api.nvim_chan_send(chan, '\003')
+ vim.api.nvim_chan_send(State.chan, '\003')
end
- last_command = cmd
- vim.api.nvim_chan_send(chan, ' ' .. cmd .. '\r')
+
+ State.last_command = cmd
+ vim.api.nvim_chan_send(State.chan, ' ' .. cmd .. '\r')
end
-- Runs the last command again
M.rerun = function()
- if last_command == nil then
+ if not State.last_command then
print('Last command empty')
return
end
- M.run(last_command)
+ M.run(State.last_command)
M.catchup()
return true
end
@@ -102,25 +87,26 @@ end
-- Jumps to the terminal window and enters insert mode. If called from the terminal window, it will jump back to the
-- previous window
M.interactive = function()
- if win_is_open() == false then
+ if not State:is_open() then
M.toggle()
end
- if vim.api.nvim_get_current_win() == winh then
+ if vim.api.nvim_get_current_win() == State.win then
vim.cmd.wincmd('w')
else
- vim.api.nvim_set_current_win(winh)
+ vim.api.nvim_set_current_win(State.win)
vim.cmd.startinsert()
end
end
-- Jump to the end of terminal buffer without moving from actual buffer
M.catchup = function()
- if win_is_open() == false then
+ if not State:is_open() then
M.toggle()
end
- if buf_is_valid() then
- vim.api.nvim_buf_call(bufh, function()
+
+ if State:is_valid() then
+ vim.api.nvim_buf_call(State.buf, function()
vim.cmd.normal('G')
end)
end