Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 'cwd' option on repl_definition? Potential PR #349

Open
damca opened this issue Aug 11, 2023 · 1 comment
Open

Allow 'cwd' option on repl_definition? Potential PR #349

damca opened this issue Aug 11, 2023 · 1 comment

Comments

@damca
Copy link

damca commented Aug 11, 2023

It could be nice to allow a repl_definition to also have a 'cwd' function:

typescript = {
  command = { "ts-node" },
  cwd = function(current_bufnr)
    local filename = vim.api.nvim_buf_get_name(current_bufnr)
    local root = require("lspconfig.util").root_pattern("node_modules", "package.json", "tsconfig.json", ".git")(filename)
    return root
  end,
  open = ".editor\n",
  close = "\04"
},

I was able to get this to work by adding the following to the lowlevel.create_repl_on_current_window function:

if type(repl.cwd) == 'string' then
  opts.cwd = repl.cwd
elseif type(repl.cwd) == 'function' then
  opts.cwd = repl.cwd(current_bufnr)
end
@hkupty
Copy link
Collaborator

hkupty commented Aug 16, 2023

That's a wonderful suggestion. I'll look into it when I have time. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants