Skip to content

chujDK/bootlin.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple telescope extension use the bootlin elixir REST api

usage

install

  • lazy
lazy {
    'chujDK/bootlin.nvim'
    dependencies = {
      'nvim-lua/plenary.nvim',
      'nvim-telescope/telescope.nvim'
    },
    event = "VeryLazy",
}

dependency

currently, the previewer is using bat to provide syntax highlighting and line highlighting

so bat is needed for preview the code in the telescope window.

needless to say, telescope.nvim is needed too.

setup

currently the code is shity, you need setup environment variable to use it..

take musl project as an example.

export NVIM_BOOTLIN_HOST='https://elixir.bootlin.com/' # set the host, you can change to your local server
export NVIM_BOOTLIN_REST_PROJECT=musl # set project's name
export NVIM_BOOTLIN_REST_PROJECT_DIR=/path/to/musl/project/you/cloned # set local source dir
export NVIM_BOOTLIN_REST_TAG=v1.2.4 # set project's version
export NVIM_BOOTLIN_ENABLE=1 # enable the plugin

use

search references of <ident>

:lua require('telescope').extensions.bootlin.bootlinElixirReferences('<ident>')

search of <ident>

:lua require('telescope').extensions.bootlin.bootlinElixirDefinitions('<ident>')

also, you can pass opts after the <ident>, like this

:lua require('telescope').extensions.bootlin.bootlinElixirDefinitions('malloc', { <your opts> })

example

I have always wanted to read the Linux source code without having to build it first and then use lsp to read it. I want to be able to simply type the version number and start reading whenever I want. So, I have created a shell script:

#!/usr/bin/env bash

project_dir=/home/chuj/projects/c/linux/
tag=`git -C $project_dir tag | tac | fzf --query 'v' --prompt "chose a tag:"`
git -C $project_dir checkout $tag

NVIM_BOOTLIN_HOST='http://172.17.0.2' \
  NVIM_BOOTLIN_REST_PROJECT=linux \
  NVIM_BOOTLIN_REST_PROJECT_DIR=$project_dir \
  NVIM_BOOTLIN_REST_TAG=$tag \
  NVIM_LSP_C_SUPPRESS=1 \
  NVIM_BOOTLIN_ENABLE=1 \
  BAT_THEME="Visual Studio Dark+" nvim -R -c ":cd $project_dir"

Save this as bootlin_nvim_read_linux.

Then bind gd and gr to search defs/refs.

Note: You may find that, unlike lsp, gd can only search for global definitions in this case. This is because lsp can intelligently recognize whether ident is global or local, while tag-based methods require manual selection of whether to search for local or global definitions. It is recommended to map gD to gd, so that you can use the gD key to search for local definitions using Vim's built-in regular expression search method.

Here goes the demo:

bootlin-nvim-demo

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages