*live-server.txt* Live reload for web development Author: Barrett Ruth Homepage: =============================================================================== INTRODUCTION *live-server.nvim* live-server.nvim automatically reloads HTML, CSS, and JavaScript files in the browser via a local development server. =============================================================================== REQUIREMENTS *live-server-requirements* - Neovim >= 0.9.0 - live-server npm package (`npm install -g live-server`) =============================================================================== CONFIGURATION *live-server-config* *vim.g.live_server* Configure via `vim.g.live_server` before the plugin loads: >lua vim.g.live_server = { args = { '--port=8080', '--no-browser' }, } < *live_server.Config* Fields: ~ {args} (`string[]`) Arguments passed to live-server via |vim.fn.jobstart()|. Run `live-server --help` to see available options. Default: `{ '--port=5555' }` =============================================================================== COMMANDS *live-server-commands* *:LiveServerStart* :LiveServerStart [dir] Start the live server. If `dir` is provided, the server starts in the specified directory. Otherwise, uses the directory of the current file. *:LiveServerStop* :LiveServerStop [dir] Stop the live server. If `dir` is provided, stops the server running in the specified directory. *:LiveServerToggle* :LiveServerToggle [dir] Toggle the live server on or off. If `dir` is provided, toggles the server in that directory. =============================================================================== MAPPINGS *live-server-mappings* *(live-server-start)* (live-server-start) Start the live server. Equivalent to |:LiveServerStart| with no arguments. *(live-server-stop)* (live-server-stop) Stop the live server. Equivalent to |:LiveServerStop| with no arguments. *(live-server-toggle)* (live-server-toggle) Toggle the live server. Equivalent to |:LiveServerToggle| with no arguments. Example configuration: >lua vim.keymap.set('n', 'ls', '(live-server-start)') vim.keymap.set('n', 'lx', '(live-server-stop)') vim.keymap.set('n', 'lt', '(live-server-toggle)') < =============================================================================== API *live-server-api* All functions accept an optional `dir` parameter. When omitted, the directory of the current file is used. live_server.start({dir}) *live_server.start()* Start the live server in the specified directory. Parameters: ~ {dir} (`string?`) Directory to serve live_server.stop({dir}) *live_server.stop()* Stop the live server running in the specified directory. Parameters: ~ {dir} (`string?`) Directory of running server live_server.toggle({dir}) *live_server.toggle()* Toggle the live server on or off. Parameters: ~ {dir} (`string?`) Directory to toggle live_server.setup({user_config}) *live_server.setup()* Deprecated: Use |vim.g.live_server| instead. Parameters: ~ {user_config} (|live_server.Config|?) Configuration table =============================================================================== EXAMPLES *live-server-examples* Start server in project root: >vim :LiveServerStart ~/projects/my-website < Lua keybinding to toggle server: >lua vim.keymap.set('n', 'ls', '(live-server-toggle)') < Configuration with custom port and no auto-open: >lua vim.g.live_server = { args = { '--port=3000', '--no-browser' }, } < ------------------------------------------------------------------------------- vim:tw=78:ft=help:norl: