Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Attached A Neovim Buffer To An LSP Based Off File Extension

I'm working on an LSP to use with Neopolitan in Neovim. The first hurdle was figuring out how to attach a file to the LSP. This is how I'm doing it.

Code

vim.api.nvim_create_autocmd("BufReadPost", {
  pattern = "*.tmp",
  group = vim.api.nvim_create_augroup("LSPTestGroup", { clear = true }),
  callback = function() 
    vim.lsp.start({
      name = 'neopolitan',
      cmd = {'/Users/alan/workshop/neopolitan-lsp/target/debug/nrs-language-server'},
      root_dir = vim.fs.dirname(vim.fs.find({'Cargo.toml'}, { upward = true })[1]),
    })
  end,
})

References