artempyanykh/marksman

NeoVim: No completion working, even though LSP attaches and is available as source

Opened this issue · 6 comments

I have installed Marksman with Mason, and set it up with LSP config.
My config works for all other LSP servers, but marksman does not work at all. No autocompletion, linking etc.
The LSP does attach to the buffer:
marksmanattached

CmpStatus shows that it is available as a source:
Screenshot 2024-02-01 at 17 27 23

The LspLog output the following messages when opening a markdown file:
[START][2024-02-01 04:25:48] LSP logging initiated
[ERROR][2024-02-01 04:25:48] .../vim/lsp/rpc.lua:734 | "rpc" | "/Users/[username]/.local/share/nvim/mason/bin/marksman" | "stderr" | "[04:25:48 INF] <LSP Entry> Starting Marksman LSP server: {}\n"

This is my LSP config (I'm using nvim-cmp for completion):

return {
    'williamboman/mason.nvim',
    dependencies = {
        'williamboman/mason-lspconfig.nvim',
        'neovim/nvim-lspconfig',
        'hrsh7th/cmp-nvim-lsp',
    },
    config = function()
        require('mason').setup { }
        require('mason-lspconfig').setup {
            ensure_installed = { 'bashls', 'lua_ls', 'texlab', 'pyright', 'taplo', 'marksman' },
            automatic_installation = true
        }
        require('mason-lspconfig').setup_handlers {
            function(server)
                require('lspconfig')[server].setup{
                    capabilities = require('cmp_nvim_lsp').default_capabilities(),
                }
            end
        }
    end
}

and my nvim-cmp config:

return {
    'hrsh7th/nvim-cmp',
    dependencies = {
        'hrsh7th/cmp-buffer',
        'hrsh7th/cmp-path',
        'hrsh7th/cmp-cmdline',
        'hrsh7th/cmp-nvim-lua',
        'L3MON4D3/LuaSnip',
        'saadparwaiz1/cmp_luasnip',
        'hrsh7th/cmp-nvim-lsp',
    },
    config = function()
        local cmp = require('cmp')
        cmp.setup {
            snippet = {
                expand = function(args)
                    require('luasnip').lsp_expand(args.body)
                end
            },
            mapping = cmp.mapping.preset.insert {
                ['<C-k>'] = cmp.mapping.confirm({ select = true }),
                ['<C-d>'] = cmp.mapping.scroll_docs(-4),
                ['<C-f>'] = cmp.mapping.scroll_docs(4),
            },
            sources = {
                { name = 'luasnip' },
                { name = 'nvim_lsp' },
                { name = 'nvim_lua' },
                { name = 'buffer', keyword_length = 3 },
                { name = 'path' },
            },
            formatting = {
                format = function(entry, vim_item)
                    local abbrev = {
                        buffer = "buf",
                        nvim_lsp = "LSP",
                        nvim_lua = "nvim",
                        path = "path",
                        luasnip = "snip",
                        cmdline = "cmd"
                    }
                    local source = entry.source.name
                    vim_item.menu = "[" .. abbrev[source] .. "]"
                    return vim_item
                end
            }
        }
        cmp.setup.cmdline(':', {
            mapping = cmp.mapping.preset.cmdline(),
            sources = {
                { name = 'path' },
                { name = 'cmdline' },
            }
        })
        cmp.setup.cmdline('/', {
            mapping = cmp.mapping.preset.cmdline(),
            sources = {
                { name = 'buffer' },
            }
        })
        vim.api.nvim_set_keymap('i', '<c-h>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', { noremap = true, silent = true })
    end
}

Originally posted by @soer9459 in #294

Same here for me. Almost the exact config settings, same CmpStatus, same LspInfo output. I also checked out these similar issues: #204 (comment) and #11 (comment). But didn't change anything.

Would appreciate a solution very much, since my notes are kind of hard to skim through without working completion for links etc.

Edit: I further tried to add an .marksman.toml file to my notes folder (as suggested here). Now at least the checking system works and warns me if the wikilink has an unknown filename. But completion suggestions are still not available...

Same here for me. Almost the exact config settings, same CmpStatus, same LspInfo output. I also checked out these similar issues: #204 (comment) and #11 (comment). But didn't change anything.

Would appreciate a solution very much, since my notes are kind of hard to skim through without working completion for links etc.

Edit: I further tried to add an .marksman.toml file to my notes folder (as suggested here). Now at least the checking system works and warns me if the wikilink has an unknown filename. But completion suggestions are still not available...

Yes, I have exactly the same experience. Adding the .marksman.toml file adds wiki-link completion and check for correct referencing. No other features are available though

Had the same issue, after adding .marksman.toml to the root of my nots directory i got completion and go to definition working

Which ig makes sense, since it needs some reference point where to start scanning from

Here are my setup specs:

$ nvim --version
NVIM v0.10.0-dev-2680+gd3e51603b
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
Run "nvim -V1 -v" for more info

Using lazy with lspconfig

lspconfig.marksman.setup({})

I may be a little late to the party but I got similar issues. References are working but neither highlighting nor completion seems to work.

NeoVim information

$ nvim --version
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1692716794

I use lsp-zero which is based on lsp-config and Mason. My lsp config for marksman looks like this:

lsp.configure("marksman", {
    -- on_attach = function(client, bufnr)
    --     ih.on_attach(client, bufnr)
    -- end,
    cmd = { "marksman", "server" }
})

The commented out part was only for inlay-hints integration. I thought this might be the problem but it was not.

After reading this thread, I created the .marksman.toml file at my projects root and also got debug logs. They look like this:

[INFO][2024-04-15 15:59:58] .../vim/lsp/rpc.lua:662	"Starting RPC client"	{  args = { "server" },  cmd = "/home/<user>/.local/share/nvim/mason/bin/marksman",  extra = {    cwd = "/home/<user>/Development/sldde"  }}
[DEBUG][2024-04-15 15:59:58] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      textDocument = {        callHierarchy = {          dynamicRegistration = false        },        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }            }          },          dataSupport = true,          dynamicRegistration = false,          isPreferredSupport = true,          resolveSupport = {            properties = { "edit" }          }        },        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            documentationFormat = { "markdown", "plaintext" },            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionItemKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          insertTextMode = 1        },        declaration = {          linkSupport = true        },        definition = {          linkSupport = true        },        documentHighlight = {          dynamicRegistration = false        },        documentSymbol = {          dynamicRegistration = false,          hierarchicalDocumentSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        foldingRange = {          dynamicRegistration = false,          lineFoldingOnly = true        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false        },        implementation = {          linkSupport = true        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 }          }        },        references = {          dynamicRegistration = false        },        rename = {          dynamicRegistration = false,          prepareSupport = true        },        semanticTokens = {          augmentsSyntaxTokens = true,          dynamicRegistration = false,          formats = { "relative" },          multilineTokenSupport = false,          overlappingTokenSupport = true,          requests = {            full = {              delta = true            },            range = false          },          serverCancelSupport = false,          tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },          tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            activeParameterSupport = true,            documentationFormat = { "markdown", "plaintext" },            parameterInformation = {              labelOffsetSupport = true            }          }        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = true,          willSaveWaitUntil = true        },        typeDefinition = {          linkSupport = true        }      },      window = {        showDocument = {          support = true        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false          }        },        workDoneProgress = true      },      workspace = {        applyEdit = true,        configuration = true,        didChangeWatchedFiles = {          dynamicRegistration = false,          relativePatternSupport = true        },        semanticTokens = {          refreshSupport = true        },        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        workspaceEdit = {          resourceOperations = { "rename", "create", "delete" }        },        workspaceFolders = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.4"    },    initializationOptions = vim.empty_dict(),    processId = 99037,    rootPath = "/home/<user>/Development/sldde",    rootUri = "file:///home/<user>/Development/sldde",    trace = "off",    workspaceFolders = { {        name = "/home/<user>/Development/sldde",        uri = "file:///home/<user>/Development/sldde"      } }  }}
[ERROR][2024-04-15 15:59:59] .../vim/lsp/rpc.lua:734	"rpc"	"/home/<user>/.local/share/nvim/mason/bin/marksman"	"stderr"	"[15:59:59 INF] <LSP Entry> Starting Marksman LSP server: {}\n"
[DEBUG][2024-04-15 16:00:00] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      codeActionProvider = {        resolveProvider = false      },      codeLensProvider = vim.empty_dict(),      completionProvider = {        triggerCharacters = { "[", "#", "(" }      },      definitionProvider = true,      documentSymbolProvider = true,      executeCommandProvider = {        commands = {}      },      hoverProvider = true,      referencesProvider = true,      renameProvider = {        prepareProvider = true      },      semanticTokensProvider = {        full = {          delta = false        },        legend = {          tokenModifiers = {},          tokenTypes = { "class", "class", "enumMember" }        },        range = true      },      textDocumentSync = {        change = 1,        openClose = true      },      workspace = {        fileOperations = {          didCreate = {            filters = { {                pattern = {                  glob = "**/*.{md,markdown}",                  matches = "file",                  options = {                    ignoreCase = true                  }                }              } }          },          didDelete = {            filters = { {                pattern = {                  glob = "**/*.{md,markdown}",                  matches = "file",                  options = {                    ignoreCase = true                  }                }              } }          }        },        workspaceFolders = {          changeNotifications = true,          supported = true        }      },      workspaceSymbolProvider = true    }  }}
[DEBUG][2024-04-15 16:00:00] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "initialized",  params = vim.empty_dict()}
[INFO][2024-04-15 16:00:00] .../lua/vim/lsp.lua:1344	"LSP[marksman]"	"server_capabilities"	{  server_capabilities = {    codeActionProvider = {      resolveProvider = false    },    codeLensProvider = vim.empty_dict(),    completionProvider = {      triggerCharacters = { "[", "#", "(" }    },    definitionProvider = true,    documentSymbolProvider = true,    executeCommandProvider = {      commands = {}    },    hoverProvider = true,    referencesProvider = true,    renameProvider = {      prepareProvider = true    },    semanticTokensProvider = {      full = {        delta = false      },      legend = {        tokenModifiers = {},        tokenTypes = { "class", "class", "enumMember" }      },      range = true    },    textDocumentSync = {      change = 1,      openClose = true    },    workspace = {      fileOperations = {        didCreate = {          filters = { {              pattern = {                glob = "**/*.{md,markdown}",                matches = "file",                options = {                  ignoreCase = true                }              }            } }        },        didDelete = {          filters = { {              pattern = {                glob = "**/*.{md,markdown}",                matches = "file",                options = {                  ignoreCase = true                }              }            } }        }      },      workspaceFolders = {        changeNotifications = true,        supported = true      }    },    workspaceSymbolProvider = true  }}
[DEBUG][2024-04-15 16:00:00] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "markdown",      text = "<some requirements.md file content>",      uri = "file:///home/<user>/Development/sldde/doc/requirements.md",      version = 0    }  }}
[DEBUG][2024-04-15 16:00:00] .../lua/vim/lsp.lua:1391	"LSP[marksman]"	"client.request"	2	"textDocument/semanticTokens/full"	{  textDocument = {    uri = "file:///home/<user>/Development/sldde/doc/requirements.md"  }}	<function 1>	4
[DEBUG][2024-04-15 16:00:00] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 2,  jsonrpc = "2.0",  method = "textDocument/semanticTokens/full",  params = {    textDocument = {      uri = "file:///home/<user>/Development/sldde/doc/requirements.md"    }  }}
[DEBUG][2024-04-15 16:00:00] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 2,  jsonrpc = "2.0",  result = {    data = {}  }}

I do not know anything about the LS protocoll but the last rpc.receive only contains empty data. Maybe that is normal but idk. Just seems odd to me.

I also tested it with a minimalistic Markdown file since the one I want to edit is pretty large. It yielded the same log output except different paths and file content as you would expect but it was not working either.

gjf7 commented

Same here

dnjp commented

I ran into a similar issue, and fixed it by ensuring that on_attach and capabilities are defined in the setup for the marksman server like this.