0

Plugins for cmp

  use("hrsh7th/nvim-cmp") -- completion plugin
  use("hrsh7th/cmp-buffer") -- source for text in buffer
  use("hrsh7th/cmp-path") -- source for file system paths
  use("hrsh7th/cmp-nvim-lua") -- source for file system paths
  use("hrsh7th/cmp-nvim-lsp") -- source for file system paths

Config for nvim-cmp

 -- Set up nvim-cmp.
  local cmp = require'cmp'
  cmp.setup({
    snippet = {
      -- REQUIRED - you must specify a snippet engine
      expand = function(args)
        vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
        -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
        -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
        -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
        -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
      end,
    },
    window = {
      -- completion = cmp.config.window.bordered(),
      -- documentation = cmp.config.window.bordered(),
    },
    mapping = cmp.mapping.preset.insert({
      ['<C-b>'] = cmp.mapping.scroll_docs(-4),
      ['<C-f>'] = cmp.mapping.scroll_docs(4),
      ['<C-Space>'] = cmp.mapping.complete(),
      ['<C-e>'] = cmp.mapping.abort(),
      ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
    }),
    sources = cmp.config.sources({
      { name = 'nvim_lsp' },
      { name = 'vsnip' }, -- For vsnip users.
      -- { name = 'luasnip' }, -- For luasnip users.
      -- { name = 'ultisnips' }, -- For ultisnips users.
      -- { name = 'snippy' }, -- For snippy users.
    }, {
      { name = 'buffer' },
    })
  })

  -- Set configuration for specific filetype.
  cmp.setup.filetype('gitcommit', {
    sources = cmp.config.sources({
      { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
    }, {
      { name = 'buffer' },
    })
  })

  -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline({ '/', '?' }, {
    mapping = cmp.mapping.preset.cmdline(),
    sources = {
      { name = 'buffer' }
    }
  })

  -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
      { name = 'path' }
    }, {
      { name = 'cmdline' }
    }),
    matching = { disallow_symbol_nonprefix_matching = false }
  })

And settings for lspconfig

-- Setup language servers.
local lspconfig = require('lspconfig')
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
--   capabilities = capabilities
-- }
lspconfig.lua_ls.setup {
  capabilities = capabilities
}
lspconfig.tsserver.setup {
  capabilities = capabilities
}
lspconfig.volar.setup {
  capabilities = capabilities
}
lspconfig.pyright.setup {
  capabilities = capabilities
}
lspconfig.intelephense.setup {
  capabilities = capabilities,
  filetypes = { "php" },
  settings = {
    intelephense = {
      files = {
        maxSize = 1000000,
      },
      environment = {
        includePaths = {
          "/home/serii/Sites/wordpress",
          "/home/serii/Sites/advanced-custom-fields-pro",
          "/home/serii/Sites/woocommerce",
        },
      },
    },
  }
}

And now in php wordpress file i don't have path autocomplete

<div class="home-intro">
<?php echo get_template_part('template-parts/'); ?>
</div>

Thanks for answer.

4
  • Can you please execute :LspInfo and give me the output of the lines Configured servers list and [n] client(s) attached to this buffer? :)
    – Bog
    Apr 3 at 10:56
  • 1
    :h i_CTRL-X_CTRL-F Apr 3 at 12:27
  • ctrl+x ctrl+f it's working, thanks.
    – serii
    Apr 3 at 15:46
  • @Bog, LspInfo ``` Language client log: /home/serii/.local/state/nvim/lsp.log Detected filetype: php 1 client(s) attached to this buffer: Client: intelephense (id: 1, bufnr: [1]) filetypes: php autostart: true root directory: /home/serii/Local/lc-vite/app/public/wp-content/themes/bs-vite cmd: /home/serii/.local/share/nvim/mason/bin/intelephense --stdio Configured servers list: pyright, intelephense, emmet_ls, cssls, rust_analyzer, lua_ls, tsserver, volar ```
    – serii
    Apr 3 at 15:47

1 Answer 1

1

Path completion in Vim is triggered by C-x C-f; see :help omnicomplete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.