Giter Site home page Giter Site logo

liadoz / nvim-dap-repl-highlights Goto Github PK

View Code? Open in Web Editor NEW
109.0 4.0 5.0 300 KB

Add syntax highlighting to the nvim-dap REPL

Python 1.22% C++ 2.82% JavaScript 3.70% Rust 10.56% Lua 9.39% Scheme 0.17% C 72.14%
debug-adapter-protocol neovim neovim-plugin

nvim-dap-repl-highlights's Introduction

nvim-dap-repl-highlights

Add syntax highlighting to the nvim-dap REPL buffer using treesitter.

Before After
before image

Requirements

Setup

Install the plugin and the requirements using your favourite method. Once installed, make sure you configured treesitter highlighting then add the following to your lua config

require('nvim-dap-repl-highlights').setup()

After initially setting up the plugin the dap_repl parser needs to be installed, this can be done manually by running :TSInstall dap_repl or by using the ensure_installed option of nvim-treesitter. NOTE: If you use the ensure_installed option you must first setup nvim-dap-repl-highlights or else the dap_repl parser won't be found, for example

require('nvim-dap-repl-highlights').setup()
require('nvim-treesitter.configs').setup {
  highlight = {
    enable = true,
  },
  ensure_installed = { 'dap_repl', ... },
  ...
}

Usage

By default, the plugin detects the language to use in the REPL by looking at the filetype used to to launch dap. Obviously in order to have syntax highlighting for certain language you will need to have a treesitter parser for that language, alongside the dap_repl parser. This may not fit all use cases.

You could instead use the command :lua require('nvim-dap-repl-highlights').setup_highlights('python') which will set python highlights in the current repl buffer. Alternatively the function can be called without specifiying the language, this will prompt the user for a language.

Additionally you could specify in the dap configuration the repl language to use, for example if you want your python repl to have javascript highlighting:

local dap = require('dap')
dap.configurations.python = {
  {
    name = "Python with javascript repl because I like to watch the world burn ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ",
    type = "python",
    request = "launch",
    program = "${file}",
    repl_lang = "javascript"
  },
}

The repl_lang option takes precedence over the filetype.

nvim-dap-repl-highlights's People

Contributors

gh-liu avatar liadoz avatar llllvvuu avatar serranomorante avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nvim-dap-repl-highlights's Issues

No highlights applied - Please help debugging

Hey ๐Ÿ‘‹๐Ÿพ

I think the idea of the plugin is great and I would love to use it. Unfortunately I'm unable to make it work. ๐Ÿ™ˆ

So if I run :TSInstallInfo, I can see dap_repl as installed. If I run :lua =vim.treesitter.inspect_language('dap_repl'), I get the following output:

{
  _abi_version = 14,
  fields = {},
  symbols = { { "\n", false },
    [3] = { "prompt_tag", true },
    [4] = { "continue_prompt_tag", true },
    [5] = { "source_file", true },
    [6] = { "entry", true },
    [7] = { "prompt", true },
    [8] = { "user_input", true },
    [10] = { "user_input_statement", true },
    [11] = { "user_input_content", true },
    [12] = { "output", true },
    [13] = { "output_content", true }
  }
}

Anyhow, if I start a debugging session and have the dap-repl buffer opened, I don't get any highlighting. How can I investigate further why the highlights don't apply?
I'm using a Rust project with codelldb.

Thank you very much! ๐Ÿ™๐Ÿพ

It's not enabled by default.

I just tried your plugin but it has no effect, these are the related configs:

{
  'nvim-treesitter/nvim-treesitter',
  build = ':TSUpdate',
  dependencies = {
    -- many unrelated lines omitted.
    { 'LiadOz/nvim-dap-repl-highlights', config = true },
  },
  config = function ()
    -- I also tried the next line too, same result.
    -- require('nvim-dap-repl-highlights').setup()
    require('nvim-treesitter.configs').setup {
      -- many unrelated lines omitted.
      ensure_installed = { 'dap_repl' },

No installation instructions

I tried installing this plugin with vim-plugged as usual, but it didn't activate.

Plug 'LiadOz/nvim-dap-repl-highlights'

I tried doing it manually with

:lua require('nvim-dap-repl-highlights').setup()

But I got

E5108: Error executing lua [string ":lua"]:1: module 'nvim-dap-repl-highlights' not found:
        no field package.preload['nvim-dap-repl-highlights']
        no file './nvim-dap-repl-highlights.lua'
        no file '/home/user/repositories/vim/neovim/.deps/usr/share/luajit-2.1.0-beta3/nvim-dap-repl-highlights.lua'
        no file '/usr/local/share/lua/5.1/nvim-dap-repl-highlights.lua'
        no file '/usr/local/share/lua/5.1/nvim-dap-repl-highlights/init.lua'
        no file '/home/user/repositories/vim/neovim/.deps/usr/share/lua/5.1/nvim-dap-repl-highlights.lua'
        no file '/home/user/repositories/vim/neovim/.deps/usr/share/lua/5.1/nvim-dap-repl-highlights/init.lua'
        no file './nvim-dap-repl-highlights.so'
        no file '/usr/local/lib/lua/5.1/nvim-dap-repl-highlights.so'
        no file '/home/user/repositories/vim/neovim/.deps/usr/lib/lua/5.1/nvim-dap-repl-highlights.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

So I looked into the repository and saw the cargo file (rust is not mentioned as a dependency). So I built it with

cargo build --release --all-features

and amended my vimrc/init

Plug 'LiadOz/nvim-dap-repl-highlights' {'do': 'cargo build --release --all-features'}

I tried again, and again it didn't work (same error as above). I don't want to run a system wide install.

Please add documentation on how to install this.

I also noticed that the directory that I used to set up vim-plugged doesn't appear in that list of error messages. It should be in ~/.vim/plugged. All my other plugins work just fine like that.

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.