From f83b76b488505720538a37b7b2bffc3c85771adb Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Tue, 28 Apr 2020 12:22:11 +0200 Subject: add documentation --- doc/nvim-treesitter.txt | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 doc/nvim-treesitter.txt (limited to 'doc') diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt new file mode 100644 index 000000000..1fc986c71 --- /dev/null +++ b/doc/nvim-treesitter.txt @@ -0,0 +1,90 @@ +*nvim-treesitter* + +Minimum version of neovim: nightly + +Authors: Yazdani Kiyan , Vigouroux Thomas <@EMAIL?> + +============================================================================== +INTRODUCTION *nvim-treesitter* + +nvim-treesitter wraps the neovim treesitter api to provide functionnalities such +as highlighting and incremental selection, and a command to easily install parsers. + +============================================================================== +QUICK START *nvim-treesitter-quickstart* + +Install the parser for your language +> +:TSInstall {language} +< + +To get a list of supported languages +> +:TSInstallInfo +< + +By default, everything is disabled. To enable support for features, in your `init.vim`: + +> + +lua < Date: Tue, 28 Apr 2020 12:32:01 +0200 Subject: add vim documentation --- doc/nvim-treesitter.txt | 50 ++++++++++++++++++++++++------------------------- doc/tags | 11 +++++++++++ 2 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 doc/tags (limited to 'doc') diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index 1fc986c71..798c5bfc1 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -2,10 +2,10 @@ Minimum version of neovim: nightly -Authors: Yazdani Kiyan , Vigouroux Thomas <@EMAIL?> +Authors: Yazdani Kiyan , Vigouroux Thomas ============================================================================== -INTRODUCTION *nvim-treesitter* +INTRODUCTION *nvim-treesitter-intro* nvim-treesitter wraps the neovim treesitter api to provide functionnalities such as highlighting and incremental selection, and a command to easily install parsers. @@ -14,41 +14,41 @@ as highlighting and incremental selection, and a command to easily install parse QUICK START *nvim-treesitter-quickstart* Install the parser for your language + > -:TSInstall {language} + :TSInstall {language} < To get a list of supported languages + > -:TSInstallInfo + :TSInstallInfo < By default, everything is disabled. To enable support for features, in your `init.vim`: > - -lua < Date: Fri, 1 May 2020 12:26:57 +0200 Subject: update docs for ensure installed, move modules config in config.modules --- README.md | 5 ++- doc/nvim-treesitter.txt | 3 +- lua/nvim-treesitter/configs.lua | 87 ++++++++++++++++++++--------------------- 3 files changed, 48 insertions(+), 47 deletions(-) (limited to 'doc') diff --git a/README.md b/README.md index bc1f17ef8..3903ecb0b 100644 --- a/README.md +++ b/README.md @@ -96,10 +96,11 @@ require'nvim-treesitter.configs'.setup { enable = true, disable = { 'cpp', 'lua' }, keymaps = { -- mappings for incremental selection (visual mappings) - node_incremental = "e", -- "grn" by default, + node_incremental = "e", -- "grn" by default, scope_incremental = "f" -- "grc" by default } - } + }, + ensure_installed = 'all' -- one of 'all', 'language', or a list of languages } EOF ``` diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index 798c5bfc1..55ada1596 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -41,7 +41,8 @@ By default, everything is disabled. To enable support for features, in your `ini node_incremental = "e", -- "grn" by default, scope_incremental = "f" -- "grc" by default } - } + }, + ensure_installed = 'all' -- can be one of 'all', 'language' or {'language1', 'language2' ... } } < diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index eabe3e3bd..90ab92c4c 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -150,28 +150,31 @@ parsers.tsx = { -- @keymaps list of user mappings for a given module if relevant -- @is_supported function which, given a ft, will return true if the ft works on the module local config = { - highlight = { - enable = false, - disable = {}, - is_supported = function(ft) - return queries.get_query(ft, 'highlights') ~= nil - end - }, - textobj = { - enable = false, - disable = {}, - keymaps = { - node_incremental="grn", - scope_incremental="grc" + modules = { + highlight = { + enable = false, + disable = {}, + is_supported = function(ft) + return queries.get_query(ft, 'highlights') ~= nil + end + }, + textobj = { + enable = false, + disable = {}, + keymaps = { + node_incremental="grn", + scope_incremental="grc" + }, + is_supported = function() return true end }, - is_supported = function() return true end + -- folding = { + -- enable = false, + -- disable = {}, + -- keymaps = {}, + -- is_supported = function() return false end + -- } }, - -- folding = { - -- enable = false, - -- disable = {}, - -- keymaps = {}, - -- is_supported = function() return false end - -- } + ensure_installed = nil } local M = {} @@ -179,7 +182,7 @@ local M = {} local function enable_module(mod, bufnr, ft) local bufnr = bufnr or api.nvim_get_current_buf() local ft = ft or api.nvim_buf_get_option(bufnr, 'ft') - if not parsers[ft] or not config[mod] then + if not parsers[ft] or not config.modules[mod] then return end @@ -188,20 +191,20 @@ local function enable_module(mod, bufnr, ft) end local function enable_mod_conf_autocmd(mod, ft) - if not config[mod] or M.is_enabled(mod, ft) then return end + if not config.modules[mod] or M.is_enabled(mod, ft) then return end local cmd = string.format("lua require'nvim-treesitter.%s'.attach()", mod) api.nvim_command(string.format("autocmd FileType %s %s", ft, cmd)) - for i, parser in pairs(config[mod].disable) do + for i, parser in pairs(config.modules[mod].disable) do if parser == ft then - table.remove(config[mod].disable, i) + table.remove(config.modules[mod].disable, i) break end end end local function enable_all(mod, ft) - if not config[mod] then return end + if not config.modules[mod] then return end for _, bufnr in pairs(api.nvim_list_bufs()) do if not ft or api.nvim_buf_get_option(bufnr, 'ft') == ft then @@ -219,13 +222,13 @@ local function enable_all(mod, ft) end end end - config[mod].enable = true + config.modules[mod].enable = true end local function disable_module(mod, bufnr, ft) local bufnr = bufnr or api.nvim_get_current_buf() local ft = ft or api.nvim_buf_get_option(bufnr, 'ft') - if not parsers[ft] or not config[mod] then + if not parsers[ft] or not config.modules[mod] then return end @@ -234,10 +237,10 @@ local function disable_module(mod, bufnr, ft) end local function disable_mod_conf_autocmd(mod, ft) - if not config[mod] or not M.is_enabled(mod, ft) then return end + if not config.modules[mod] or not M.is_enabled(mod, ft) then return end api.nvim_command(string.format("autocmd! FileType %s", ft)) - table.insert(config[mod].disable, ft) + table.insert(config.modules[mod].disable, ft) end local function disable_all(mod, ft) @@ -252,7 +255,7 @@ local function disable_all(mod, ft) for _, ft in pairs(M.available_parsers()) do disable_mod_conf_autocmd(mod, ft) end - config[mod].enable = false + config.modules[mod].enable = false end end @@ -298,7 +301,7 @@ function M.is_enabled(mod, ft) return false end - local module_config = M.get_config()[mod] + local module_config = config.modules[mod] if not module_config then return false end if not module_config.enable or not module_config.is_supported(ft) then @@ -315,27 +318,23 @@ function M.setup(user_data) if not user_data then return end for mod, data in pairs(user_data) do - if config[mod] then + if config.modules[mod] then if type(data.enable) == 'boolean' then - config[mod].enable = data.enable + config.modules[mod].enable = data.enable end if type(data.disable) == 'table' then - config[mod].disable = data.disable + config.modules[mod].disable = data.disable end - if config[mod].keymaps and type(data.keymaps) == 'table' then - config[mod].keymaps = data.keymaps - end - if mod == 'ensure_installed' then - require'nvim-treesitter/install'.ensure_installed(data) + if config.modules[mod].keymaps and type(data.keymaps) == 'table' then + config.modules[mod].keymaps = data.keymaps end + elseif mod == 'ensure_installed' then + config.ensure_installed = data + require'nvim-treesitter/install'.ensure_installed(data) end end end -function M.get_config() - return config -end - function M.get_parser_configs() return parsers end @@ -345,7 +344,7 @@ function M.available_parsers() end function M.available_modules() - return vim.tbl_keys(config) + return vim.tbl_keys(config.modules) end return M -- cgit v1.3 From a33bccaaf0c69146dfe330feb52e05c975054468 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 3 May 2020 11:10:36 +0200 Subject: Add documentation for `node_movement`, rename: `textobj` -> `incremental_selection` --- README.md | 13 ++++++++++++- doc/nvim-treesitter.txt | 36 +++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 14 deletions(-) (limited to 'doc') diff --git a/README.md b/README.md index 3903ecb0b..67d90abbc 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ require'nvim-treesitter.configs'.setup { enable = true, -- false will disable the whole extension disable = { 'c', 'rust' }, -- list of language that will be disabled }, - textobj = { -- this enables incremental selection + incremental_selection = { -- this enables incremental selection enable = true, disable = { 'cpp', 'lua' }, keymaps = { -- mappings for incremental selection (visual mappings) @@ -100,6 +100,16 @@ require'nvim-treesitter.configs'.setup { scope_incremental = "f" -- "grc" by default } }, + node_movement = { -- this cursor movement in node hierachy + enable = true, + disable = { 'cpp', 'rust' }, + keymaps = { -- mappings for node movement (normal mappings) + move_up = "", -- default is to move with alt key hold + move_down = "", + move_left = "", + move_right = "", + } + }, ensure_installed = 'all' -- one of 'all', 'language', or a list of languages } EOF @@ -124,6 +134,7 @@ Some of these features are : - [x] Incremental selection - [ ] Syntax based code folding - [x] Consistent syntax highlighting (the api is not quite stable yet) + - [x] Cursor movement in node hierachy You can find the roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/projects/1). The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated! diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index 55ada1596..ceb834be1 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -30,19 +30,29 @@ By default, everything is disabled. To enable support for features, in your `ini > lua < Date: Thu, 7 May 2020 08:18:13 +0200 Subject: docs: add statusline indicator informations. Also document newly added parsers by adding them in the readme. --- README.md | 8 ++++++++ doc/nvim-treesitter.txt | 13 ++++++++++++- doc/tags | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/README.md b/README.md index 67d90abbc..5dcfc4478 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ Some of these features are : - [ ] Syntax based code folding - [x] Consistent syntax highlighting (the api is not quite stable yet) - [x] Cursor movement in node hierachy + - [x] Statusline indicator (`require'nvim-treesitter'.statusline(size)`) You can find the roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/projects/1). The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated! @@ -166,6 +167,13 @@ List of currently supported languages: - [ ] julia - [ ] php - [ ] bash +- [ ] scala +- [ ] haskell +- [ ] toml +- [ ] vue +- [ ] elm +- [ ] yaml +- [ ] nix ## Troubleshooting Before doing anything run `:checkhealth nvim_treesitter`. This will help you find where the bug might come from. diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index ceb834be1..084936bad 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -97,5 +97,16 @@ A list of languages can be found at |:TSInstallInfo| List modules state for the current session. - vim:tw=78:ts=8:noet:ft=help:norl: +============================================================================== +FUNCTIONS~ + *nvim-treesitter-functions* + +|nvim_treesitter#statusline(size)| + *nvim_treesitter#statusline()* +Returns a string describing the current position in the syntax tree. This +could be used as a statusline indicator. +Note: The `size` argument is optionnal. When specified, the string will not be + longer than `size`. + + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/doc/tags b/doc/tags index 7d69206e3..f712ecf00 100644 --- a/doc/tags +++ b/doc/tags @@ -7,5 +7,7 @@ :TSModuleInfo nvim-treesitter.txt /*:TSModuleInfo* nvim-treesitter nvim-treesitter.txt /*nvim-treesitter* nvim-treesitter-commands nvim-treesitter.txt /*nvim-treesitter-commands* +nvim-treesitter-functions nvim-treesitter.txt /*nvim-treesitter-functions* nvim-treesitter-intro nvim-treesitter.txt /*nvim-treesitter-intro* nvim-treesitter-quickstart nvim-treesitter.txt /*nvim-treesitter-quickstart* +nvim_treesitter#statusline() nvim-treesitter.txt /*nvim_treesitter#statusline()* -- cgit v1.3