Skip to content

ngtuonghy/live-server-nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

live-server-nvim: plugin to run live-server in neovim

demo-live-server.mov

Features

  • Always find and run the index.html file regardless of where you are in the project root
  • Run the currently opened file

Requiements

Installation

  • install the plugin with lazy.nvim as you would for any other:
 require("lazy").setup({
  {
    "ngtuonghy/live-server-nvim",
    event = "VeryLazy",
    build = ":LiveServerInstall",
    config = functions()
    require("live-server-nvim").setup{}
  },
})

Configuration

  • live-server-nvim will not run without setup
require('live-server-nvim').setup {
    custom = {
        "--port=8080",
        "--no-css-inject",
    },
 serverPath = vim.fn.stdpath("data") .. "/live-server/", --default
 open = "folder", -- folder|cwd     --default
}

Usage

LiveServerStart--Run server
LiveServerStart -f    -- Serve the currently open file (Note: for this to work, `open` mode in setup must be set to "folder")
LiveServerStop --Stop server
LiveServerToggle --Toggle server

Custom mappings

vim.keymap.set("n", "<leader>lt", function() require("live-server-nvim").toggle() end)

Contributors

Many thanks to those who have contributed to the project!

@beka-birhanu