Skip to content

Commit 3327656

Browse files
fix(ui): use rest_nvim_result filetype for all panes (fix #424)
1 parent 58c3f29 commit 3327656

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

lua/rest-nvim/commands.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ local rest_command_tbl = {
100100
},
101101
run = {
102102
impl = function(args, opts)
103-
if vim.bo.filetype ~= "http" or vim.b.__rest_no_http_file then
103+
if vim.bo.filetype ~= "http" then
104104
vim.notify(
105105
"`:Rest run` can be only called from http file",
106106
vim.log.levels.ERROR,

lua/rest-nvim/logger.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
local logger = {}
1111

12-
---@type fun(any)
12+
---@type fun(...)
1313
function logger.trace(_) end
14-
---@type fun(any)
14+
---@type fun(...)
1515
function logger.debug(_) end
16-
---@type fun(any)
16+
---@type fun(...)
1717
function logger.info(_) end
18-
---@type fun(any)
18+
---@type fun(...)
1919
function logger.warn(_) end
20-
---@type fun(any)
20+
---@type fun(...)
2121
function logger.error(_) end
2222

2323
local default_log_path = vim.fn.stdpath("log") --[[@as string]]

lua/rest-nvim/ui/result.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ end
2020
---@param buffer integer
2121
---@param filetype string
2222
local function syntax_highlight(buffer, filetype)
23+
logger.debug("syntax_highlight", buffer, filetype)
2324
local lang = vim.treesitter.language.get_lang(filetype)
25+
logger.debug("found tree-sitter language:", lang)
2426
local ok = pcall(vim.treesitter.start, buffer, lang)
25-
if not ok then
27+
logger.debug("ok:", ok)
28+
if not lang or not ok then
2629
vim.bo[buffer].syntax = filetype
30+
logger.debug("set syntax to", vim.bo[buffer].syntax)
2731
end
2832
end
2933

@@ -61,9 +65,7 @@ local panes = {
6165
end
6266
-- HACK: `vim.treesitter.foldexpr()` finds fold based on filetype not registered parser of
6367
-- current buffer
64-
vim.bo[self.bufnr].filetype = "http"
65-
vim.b[self.bufnr].__rest_no_http_file = true
66-
-- syntax_highlight(self.bufnr, "http")
68+
syntax_highlight(self.bufnr, "rest_nvim_result")
6769
local lines = render_request(data.request)
6870
if data.response then
6971
logger.debug(data.response.status)

plugin/rest-nvim.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@ vim.g.rest_nvim_deps = rest_nvim_deps
7272

7373
require("rest-nvim.autocmds").setup()
7474
require("rest-nvim.commands").setup()
75+
vim.treesitter.language.register("http", "rest_nvim_result")
7576

7677
vim.g.loaded_rest_nvim = true

queries/rest_nvim_result/folds.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
; inherits http
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
; inherits http
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
; inherits http

0 commit comments

Comments
 (0)