Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[not urgent] enable treesitter parsing by default #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/docs/getting-started/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Here is a full example of setting up the Kulala plugin with the available `opts`
-- set scope for environment and request variables
-- possible values: b = buffer, g = global
environment_scope = "b",

-- by default, requests are parsed using treesitter if an http parser is available.
-- if you encounter tree-sitter related issues, you can disable this feature
-- by setting this option to false (and then open an issue on GitHub!)
treesitter = true,
},
}
```
Expand Down
14 changes: 13 additions & 1 deletion lua/kulala/config/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
local FS = require("kulala.utils.fs")
local M = {}

-- enable treesitter parsing by default if http parser is available
local treesitter_default = false
local ok, parsers = pcall(require, "nvim-treesitter.parsers")
if ok then
for _, parser in pairs(parsers.available_parsers()) do
if parser == "http" then
treesitter_default = true
break
end
end
end

M.defaults = {
-- split direction
-- possible values: "vertical", "horizontal"
Expand Down Expand Up @@ -64,7 +76,7 @@ M.defaults = {
-- enable reading vscode rest client environment variables
vscode_rest_client_environmentvars = false,
-- parse requests with tree-sitter
treesitter = false,
treesitter = treesitter_default,
-- disable the vim.print output of the scripts
-- they will be still written to disk, but not printed immediately
disable_script_print_output = false,
Expand Down
4 changes: 0 additions & 4 deletions lua/kulala/parser/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if not pcall(require, "nvim-treesitter") then
return nil
end

local CONFIG = require("kulala.config")
local FS = require("kulala.utils.fs")
local STRING_UTILS = require("kulala.utils.string")
Expand Down