FoamScience / foam-language-server

A language server for OpenFOAM case files
25 stars 0 forks source link

Macro expansion behavior #12

Open evanhorn opened 2 years ago

evanhorn commented 2 years ago

Describe the bug When expanding a macro, I have noticed two behaviors:

To Reproduce Steps to reproduce the behavior:

  1. Open an existing 0/p file with an internalField entry
  2. Add a macro$i
  3. Arrow down to internalField and add ;
  4. Result is :internalField

Expected behavior $internalField

Desktop (please complete the following information):

Additional context Minimal init.vim (modified from https://github.com/FoamScience/openfoam-nvim/blob/master/init.vim):

"
" This is a sample init.vim for nvim v0.6.0+
" to edit OpenFOAM cases files
"
"
" Plugins
call plug#begin('~/.local/share/nvim/plugged')
  " Tree-Sitter with OpenFOAM support
  Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
  " Interface to the native LSP client with OpenFOAM support
  Plug 'neovim/nvim-lspconfig'
  " Helper plugin to install language servers
  Plug 'williamboman/nvim-lsp-installer'
  " Auto-Complete plugins with snippets (or you can just attach to built-in omnifunc)
  Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
call plug#end()

lua <<EOF

-- Configuration for Tree-Sitter
-- Note that, for this to work, the filetype must be detected correctly
-- Which is handled automatically by nvim-treesitter plugin
local ts_config = require('nvim-treesitter.configs')
ts_config.setup {
    -- Or you can just :TSInstall foam cpp regex
    ensure_installed = { "foam", "cpp", "regex" },
    sync_install = false,
    ignore_install = {},
    highlight = {
        enable = true,
        disable = {},
        additional_vim_regex_highlighting = false,
    },
}

-- LSP configuration

-- I recommend using lsp_installer instead
local lsp_installer = require("nvim-lsp-installer")

-- LSP installer configuration
lsp_installer.settings({
    ui = {
        icons = {
            server_installed = "✓",
            server_pending = "➜",
            server_uninstalled = "✗"
        }
    }
})

-- Make sure these servers are installed
local servers = { 'foam_ls' }
for _, name in pairs(servers) do
  local server_is_found, server = lsp_installer.get_server(name)
  if server_is_found then
    if not server:is_installed() then
      print("Installing " .. name)
      server:install()
    end
  end
end

-- Configure servers
-- Here, just passes the global on_attach to the server
lsp_installer.on_server_ready(function(server)
  local opts = {
    on_attach = on_attach,
  }
  server:setup(opts)
end)

EOF

set termguicolors
FoamScience commented 2 years ago

Yes, this is actually intended behaviour, because the leading : denotes absolute paths in FoamExtend. It should be a config option for the LSP server. Thanks for reminding me!

I don't have much experience with coc-nvim but if there is an issue, it's probably a bug here.

This also on my list now. Will release a new version as soon as I find time to tackle this!

FoamScience commented 2 years ago

But please check with coq-nvim devs if there is an option to retain trigger chars.