Neovim Lua

Updated: 10 November 2024

~/.config/nvim/init.lua

-- Level 1 the function
function Foo() print 'bar' end
-- :lua Foo()

-- Level 2 user command using the function
vim.api.nvim_create_user_command('Foo', Foo, {})
-- :Foo

-- Level 3 function invoked by an event
vim.api.nvim_create_autocmd('TextYankPost', { callback = Foo })
-- try yanking some text

-- Level 4 map our function to a keyboard sequence
vim.keymap.set('n', 'xy', Foo)

Neovim Intelephense

Updated: 03 November 2024

Notes to assist with config and use of the Intelephense PHP LSP:

Neovim LSP log file: ~/.local/state/nvim/lsp.log

https://intelephense.com/

Install on your system npm install -g intelephense but is probably installed by Mason anyway.

See here: ./.local/share/nvim/mason/packages/intelephense/node_modules/intelephense

The root of a PHP project is identified by a .git folder or a composer.json file.

nvim-lspconfig intelephense docs

https://github.com/bmewburn

Perhaps an alternative to Intelephense https://github.com/phpactor/phpactor

Intelephense and Intelephense docs on GitHub https://github.com/bmewburn

Buying a Licence makes most of the LSP warnings disappear!

Try running command :LspInfo

Vim search

Updated: 30 June 2024

Magic

\v characters which follow, except a-zA-Z0-9_, have special meaning.
\V characters which follow have their literal meaning and must be preceded by \ to activate their special meaning.

Neovim auto commands

Updated: 25 March 2024

Flash yanked text

autocmd("TextYankPost", {
    pattern = "*",
    desc = "Highlight text on yank.",
    callback = function ()
        vim.highlight.on_yank { higroup = "Search", timeout = 150 }
    end,
})