Git Product home page Git Product logo

pkl-neovim's Introduction

pkl-neovim

This repository provides language support for Pkl for neovim.

Supported features:

Installation

This plugin requires Neovim version 0.5 or higher.

Install nvim-treesitter along side this plugin using your favorite plugin manager.

vim-plug setup

Here is a sample init.vim file using vim-plug. To complete the setup, you will need to run :PlugInstall, then restart neovim.

call plug#begin()
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'https://github.com/apple/pkl-neovim.git'
call plug#end()

" The below is required for enabling the tree-sitter syntax engine, which is used by pkl-neovim.
lua <<EOF
local hasConfigs, configs = pcall(require, "nvim-treesitter.configs")
if hasConfigs then
  configs.setup {
    ensure_installed = "pkl",
    highlight = {
      enable = true,              -- false will disable the whole extension
    },
    indent = {
      enable = true
    }
  }
end
EOF

packer.nvim setup

Here is a sample init.lua file using packer.nvim. To complete the setup, you will need to run :PackerSync, then restart neovim.

require('packer').startup(function(use)
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'

  use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} -- Treesitter syntax highlighting.
  use {'https://github.com/apple/pkl-neovim', after = "nvim-treesitter", run = ":TSInstall! pkl"} -- Pkl syntax highlighting
end)

-- The below is required for enabling the tree-sitter syntax engine, which is used by pkl-neovim.
-- Set up Treesitter languages.
require'nvim-treesitter.configs'.setup {
  ensure_installed = "all", -- or "pkl" for just this plugin.
  highlight = {
    enable = true,              -- false will disable the whole extension
  },
  indent = {
    enable = true
  }
}

lazy.nvim setup

Here’s a sample block to add your Lazy.nvim configuration. To complete the setup, restart neovim after adding this to your setup.

{
  "nvim-treesitter/nvim-treesitter",
  build = function(_)
    vim.cmd("TSUpdate")
  end,
},
{
  "https://github.com/apple/pkl-neovim",
  lazy = true,
  event = "BufReadPre *.pkl",
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
  },
  build = function()
    vim.cmd("TSInstall! pkl")
  end,
}

Troubleshooting

Some troubleshooting tips if the installation isn’t working:

  • If using neovim 0.5, ensure you are using the 0.5-compat branch of the nvim-treesitter/nvim-treesitter plugin

  • Run :TSInstall pkl to manually install the Pkl parser.

  • If syntax highlighting doesn’t work until you :edit the pkl file to reload it, ensure that the pkl-neovim plugin is configured to run after the nvim-treesitter plugin.

pkl-neovim's People

Contributors

bioball avatar dibakor avatar jayadamsmorgan avatar kleutzinger avatar timenzan 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.