Giter Club home page Giter Club logo

nvim-treesitter-powershell's Introduction

nvim-treesitter-powershell

Powershell grammar for tree-sitter

Forked from github

Description

This is a simple fork, with a prebuild powershell.so that nvim-tree-sitter can use.

It also include somes of the additionals files that nvim-tree-sitter need to work properly :

./queries/highlights.scm ./queries/textobjects.scm ./queries/folds.scm

Most of the features from nvim-tree-sitter textobjects are working just fine.

Perfect to work with Mini.ai

Build manualy

zig cc -shared -o powershell.so src/parser.c src/scanner.c -Isrc
clang -shared -o powershell.dll src/parser.c src/scanner.c -Isrc

Build by Neovim

There is a issue to build automatically with default neovim on windows. GCC installed through choco install mingw can't build on my system. The workaround is to use zig choco install zig and set is a default on nvim (see below).

Neovim TS Windows

Manual setup

This is my setup on LazyVIM, but the setup should be similar on a standard nvim setup.

./plugins/tree-sitter.lua :

return {
	{
		"nvim-treesitter/nvim-treesitter",
		config = function()
			-- Set preferred compiler order
			local install = require("nvim-treesitter.install")
			install.compilers = { "zig", "gcc" } --Use zig as default
			local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
			parser_config.powershell = {
				install_info = {
					url = parser_path, -- Directory of the installed parser ex "~/repo/tree-sitter-powershell/"
					files = { "src/parser.c", "src/scanner.c" }, -- Both need to be include in the build process of it fail
					branch = "main",
				},
				filetype = "ps1", -- Associate the parser with 'ps1' files
			}
		end,
	},
}

Using the Queries

Copy the .scm files that are i queries folder in ~/.config/nvim/queries/powershell/ or any other folder where neovim can access them : Neovim Docs

Tips

To use fold based on treesitter you need this in your config :

vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"

Shortcomings

  • Not all the possibles queries types are covered (indents,locals, etc... )
  • The parser dont detect everything perfectly (ex: comment block )

References

nvim-treesitter-powershell's People

Contributors

paysancorrezien avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.