The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Attached A Neovim Buffer To An LSP Based Off File Extension

TODO: Pull subtitle into page object
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,
})

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

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
-- lua

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,
})


-- notes

- "pattern" is for the file pattern. I'm using "*.tmp" for
demo purposes. 

- The "group" sets an autogroup that clears each
time things run to prevent multiple instances of the 
command getting installed

- The "callback" is what run when the autocmd event triggers

- vim.lsp.start() - starts an LSP client or reuses one with
the same name if there's one already running. Then it attaches
the current buffer to it 

- I'm not sure if "root_dir" is necessary. LSPs do stuff with
projects, but I don't need that for my stuff. TBD on that 

- I think there are other plugins like "mason" that deal with
this stuff for existing LSPs and I'm sure I could figure out
how to get what I'm working on set up with them at some
point. For now, this gets me started

- It's also possible there are some server connection 
settings that can get things to work automatically, but
it didn't start for me out of the box with tower-lsp
and tower-lsp-boilerplate

-- ref
-- title: Neovim LSP
-- url: https://neovim.io/doc/user/lsp.html

-- ref
-- title: Neovim LSP start()
-- url: https://neovim.io/doc/user/lsp.html#vim.lsp.start()


-- ref
-- title: Neovim LSP Extension
-- url: https://neovim.io/doc/user/lsp-extension.html

-- ref
-- title: Neovim Autocmd
-- url: https://neovim.io/doc/user/autocmd.html#autocommand

-- ref
-- title: Neovim Create Autocmd
-- url: https://neovim.io/doc/user/api.html#nvim_create_autocmd()

-- ref
-- title: Tower LSP Boilerplate
-- url: https://github.com/IWANABETHATGUY/tower-lsp-boilerplate

-- ref
-- title: Tower LSP Repo
-- url: https://github.com/ebkalderon/tower-lsp

-- ref
-- title: Tower LSP Docs
-- url: https://docs.rs/tower-lsp/latest/tower_lsp/


-- categories
-- Neovim 

-- metadata
-- date: 2023-09-25 19:24:35
-- id: 2vus3pxs
-- site: aws
-- type: post
-- status: published