Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

texel.nvim

Most simplistic way of interacting with LLM in neovim.

The idea

This plugin is a simple wrapper around tgpt CLI utility. In the most basic sense we achieve interaction with CLI application by using neovim's buffers, this gives us full power of neovim motions alongside full functionality of CLI application.

Setup (using lazy)

return {
  'DavidTelenko/texel.nvim',
  keys = {
    { '<leader>ab', desc = 'Ask with buffer', mode = { 'n' } },
    { '<leader>as', desc = 'Open scratch markdown tab', mode = { 'n' } },
    { '<leader>a', desc = 'Ask with selection', mode = { 'v' } },
  },
  --- @module "texel"
  --- @type texel.Config
  opts = {},
  config = function(_, opts)
    local texel = require 'texel'

    texel.setup(opts)

    vim.keymap.set('v', '<leader>a', function()
      texel.chat.ask.selection()
    end, { desc = 'Ask with selection' })

    vim.keymap.set('n', '<leader>ab', function()
      texel.chat.ask.buffer()
    end, { desc = 'Ask with buffer' })

    vim.keymap.set('n', '<leader>as', function()
      vim.cmd 'tabnew'
      vim.cmd 'set filetype=markdown'
    end, { desc = 'Open scratch markdown tab buffer' })
  end,
}

Default options

require('texel').setup {
  chat = {
    -- Spacers between the "question" and "answer"
    separators = {
      first = { '', '---', '' },
      last = { '---', '' },
    },
    notify = true,
    -- Sign to display in sign column near the line where output will be
    -- inserted. One character - static sign, multiple characters - animation,
    -- `nil` - disable the feature.
    signs = {
      thinking = { '|', '/', '-', '\\' },
    },
  },
  tgpt = {
    code = nil,
    key = nil,
    max_length = nil,
    model = nil,
    preprompt = nil,
    provider = nil,
    quiet = true,
    shell = nil,
    url = nil,
    whole = nil,
  },
}

Note

Please see tgpt help to understand what tgpt related options do

Note

If you're confused which type of a flag we're using check your lsp completion, or see here

Future improvements and goals

  • Implement functionality of the tgpt in lua natively.
  • Stream results line-wise or word-wise instead of the whole response.
  • Use Treesitter to stream text to particular node in AST.

About

tgpt wrapper for no nonsense ai interaction

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages