jose-elias-alvarez / typescript.nvim

A Lua plugin, written in TypeScript, to write TypeScript (Lua optional).
The Unlicense
498 stars 31 forks source link

Error in `:TypescriptRenameFile` with dressing.nvim #66

Closed bennypowers closed 1 year ago

bennypowers commented 1 year ago

copy this to /tmp/mininit.lua:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end

vim.opt.rtp:prepend(lazypath)

require 'lazy'.setup({

  'williamboman/mason-lspconfig.nvim',
  {
    'williamboman/mason.nvim',
    dependencies = 'typescript',
    config = function()
      require 'mason'.setup()
      require 'mason-lspconfig'.setup {
        ensure_installed = {'tsserver'},
      }
    end,
  },

  { 'stevearc/dressing.nvim',
    opts = {
      input = {
        enabled = true,
        buf_options = {
          number = false,
        },
        win_options = {
          winblend = 25,
          number = false,
        },
      },
    },
  },

  { 'jose-elias-alvarez/typescript.nvim',
    name = 'typescript',
    config = {
      disable_commands = false,
    },
  }

})

Then do

nvim -u /tmp/mininit.lua check.ts

And once the file loads and the server attaches, run

:TypescriptRenameFile

Observe:


Error executing Lua callback: ...cal/share/nvim/lazy/dressing.nvim/lua/dressing/input.lua:312: Invalid option name 'number'
stack traceback:
        [C]: in function 'nvim_buf_set_option'
        ...cal/share/nvim/lazy/dressing.nvim/lua/dressing/input.lua:312: in function <...cal/share/nvim/lazy/dressing.nvim/lua/dressing/input.lua:273>
        ...e/pack/packer/start/dressing.nvim/lua/dressing/patch.lua:21: in function 'input'
        ...packer/start/typescript.nvim/lua/typescript/commands.lua:20: in function <...packer/start/typescript.nvim/lua/typescript/commands.lua:18>
jose-elias-alvarez commented 1 year ago

Thanks for the reproduction steps. I don't think the issue is actually related to this plugin's usage, since with your config, this standalone command also raises an error:

:lua vim.ui.input({}, function(input) print(input) end)

I think the issue is that with your config, dressing.nvim tries to set number as a buffer-local option, but :help 'number' specifies that the option is window-local. Based on this line, it looks like you might want to try moving number from buf_options to win_options.

bennypowers commented 1 year ago

Thank you for looking into this, that was indeed the problem!