Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Use nvim_open_term (#206)
* this is for the primeagen, since he never reads anything

* stylua
  • Loading branch information
tjdevries committed Aug 2, 2021
1 parent bfe08f2 commit 4a30ce3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
1 change: 1 addition & 0 deletions .styluaignore
Expand Up @@ -3,6 +3,7 @@ data/
lua/luassert
lua/plenary/profile.lua
lua/plenary/profile/
lua/plenary/bit.lua
lua/say.lua
scratch/
scripts/
Expand Down
12 changes: 2 additions & 10 deletions README.md
Expand Up @@ -132,16 +132,8 @@ OTHER OTHER NOTE:
Take a look at some test examples [here](TESTS_README.md).

#### Colors
To have "Success" in green and "Failed" in red, you need [nvim-terminal.lua](https://github.com/norcalli/nvim-terminal.lua).
In order for it to work, make sure to run the setup function in your config.
For `init.vim`:
```vim
lua require('terminal').setup()
```
For `init.lua`:
```lua
require('terminal').setup()
```

You no longer need nvim-terminal to get this to work. We use `nvim_open_term` now.

### plenary.filetype

Expand Down
2 changes: 1 addition & 1 deletion lua/plenary/path.lua
Expand Up @@ -3,7 +3,7 @@
--- Goal: Create objects that are extremely similar to Python's `Path` Objects.
--- Reference: https://docs.python.org/3/library/pathlib.html

local bit = require 'plenary.bit'
local bit = require "plenary.bit"
local uv = vim.loop

local F = require "plenary.functional"
Expand Down
23 changes: 13 additions & 10 deletions lua/plenary/test_harness.lua
Expand Up @@ -18,15 +18,17 @@ local print_output = vim.schedule_wrap(function(_, ...)
vim.cmd [[mode]]
end)

local nvim_output = vim.schedule_wrap(function(bufnr, ...)
if not vim.api.nvim_buf_is_valid(bufnr) then
return
end
local get_nvim_output = function(job_id)
return vim.schedule_wrap(function(bufnr, ...)
if not vim.api.nvim_buf_is_valid(bufnr) then
return
end

for _, v in ipairs { ... } do
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { v })
end
end)
for _, v in ipairs { ... } do
vim.api.nvim_chan_send(job_id, v .. "\r\n")
end
end)
end

function harness.test_directory_command(command)
local split_string = vim.split(command, " ")
Expand All @@ -45,8 +47,8 @@ function harness.test_directory(directory, opts)
if not headless then
res = win_float.percentage_range_window(0.95, 0.70, opts.winopts)

res.job_id = vim.api.nvim_open_term(res.bufnr, {})
vim.api.nvim_buf_set_keymap(res.bufnr, "n", "q", ":q<CR>", {})
vim.api.nvim_buf_set_option(res.bufnr, "filetype", "terminal")

vim.api.nvim_win_set_option(res.win_id, "winhl", "Normal:Normal")
vim.api.nvim_win_set_option(res.win_id, "conceallevel", 3)
Expand All @@ -55,10 +57,11 @@ function harness.test_directory(directory, opts)
if res.border_win_id then
vim.api.nvim_win_set_option(res.border_win_id, "winhl", "Normal:Normal")
end

vim.cmd "mode"
end

local outputter = headless and print_output or nvim_output
local outputter = headless and print_output or get_nvim_output(res.job_id)

local paths = harness._find_files_to_run(directory)
for _, p in ipairs(paths) do
Expand Down

0 comments on commit 4a30ce3

Please sign in to comment.