Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS-TS-REACT Basic IDE for LunarVim #60

Open
wants to merge 5 commits into
base: js-ts-ide
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# starter.lvim
# JS-TS-REACT IDE (starter.lvim)

A great starting point for your LunarVim journey!
A great starting point for your `Javascript`, `Typescript` and `React` LunarVim journey!

## Submission Guidelines
# Configuration

- Ideally one file!
- IDE config must be added to its own branch named `lang-ide`
- try to keep it focused on the language and not your biased keybindings/options
In order to get started with this IDE setup please remember to run the following command:
`:MasonInstall typescript-language-server`
35 changes: 35 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- This whole setup assumes you are using LunarVim Nightly with Lazy as the plugin manager
-- LSP
-- For me the default LSP setup automatically installed by LunarVim is fine

-- FORMATTER
lvim.format_on_save = true -- Change this to false if you prefer

local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
{
command = "prettier",
extra_args = { "--print-width", "100" },
filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact" },
},
}

-- LINTER
local linters = require "lvim.lsp.null-ls.linters"
linters.setup {
{ command = "eslint_d", filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "vue" } },
}

-- DEBUGGER CONFIG
reload "user.debugger"

-- DEBUGGER PLUGINS
lvim.plugins = {
-- I prefer to install the plugins for the debugger this way following the official nvim-dap-vscode-js documentation on github by msxdev instead of using mason
{ "mxsdev/nvim-dap-vscode-js" },
{
"microsoft/vscode-js-debug",
lazy = true,
build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out"
},
}
1 change: 1 addition & 0 deletions lua/user/debugger/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "user.debugger.languages.js-ts"
64 changes: 64 additions & 0 deletions lua/user/debugger/languages/js-ts-react.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
local debugger_path = os.getenv("LUNARVIM_RUNTIME_DIR") .. "/site/pack/lazy/opt/vscode-js-debug"

require("dap-vscode-js").setup {
node_path = "node",
debugger_path = debugger_path,
-- debugger_cmd = { "js-debug-adapter" },
adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, -- which adapters to register in nvim-dap
}

for _, language in ipairs { "typescript", "javascript" } do
require("dap").configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "launch",
name = "Debug Jest Tests",
-- trace = true, -- include debugger info
runtimeExecutable = "node",
runtimeArgs = {
"./node_modules/jest/bin/jest.js",
"--runInBand",
},
rootPath = "${workspaceFolder}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
},
}
end

for _, language in ipairs { "typescriptreact", "javascriptreact" } do
require("dap").configurations[language] = {
{
type = "pwa-chrome",
name = "Attach - Remote Debugging",
request = "attach",
program = "${file}",
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = "inspector",
port = 9222,
webRoot = "${workspaceFolder}",
},
{
type = "pwa-chrome",
name = "Launch Chrome",
request = "launch",
url = "http://localhost:3000",
},
}
end