[nvim] feat: basic web-dev setup
add LSPs for JavaScript/HTML add Treesitter for JavaScript/HTML/markdown add support for .njk (as HTML) files
This commit is contained in:
parent
55c27719d3
commit
0e1e60f532
14
.config/nvim/after/ftplugin/javascript.lua
Normal file
14
.config/nvim/after/ftplugin/javascript.lua
Normal file
@ -0,0 +1,14 @@
|
||||
-- Author : swytch
|
||||
-- Created : Saturday Feb. 18, 2023 20:41:05 CET
|
||||
-- License : GPLv3
|
||||
-- Description : javascript settings file
|
||||
|
||||
|
||||
local format_sync_grp = vim.api.nvim_create_augroup("Format", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.js",
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ timeout_ms = 200 })
|
||||
end,
|
||||
group = format_sync_grp,
|
||||
})
|
44
.config/nvim/after/ftplugin/markdown.lua
Normal file
44
.config/nvim/after/ftplugin/markdown.lua
Normal file
@ -0,0 +1,44 @@
|
||||
-- Author : swytch
|
||||
-- Created : Saturday Feb. 18, 2023 21:54:19 CET
|
||||
-- License : GPLv3
|
||||
-- Description : markdown settings file
|
||||
|
||||
|
||||
-- Snippets
|
||||
local ls = require("luasnip")
|
||||
|
||||
-- some shorthands...
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local d = ls.dynamic_node
|
||||
|
||||
-- Returns a snippet_node wrapped around an insertNode whose initial
|
||||
-- text value is set to the current date in the desired format.
|
||||
local date_input = function(args, snip, old_state, fmt)
|
||||
local fmt = fmt or "%Y-%m-%d"
|
||||
return sn(nil, i(1, os.date(fmt)))
|
||||
end
|
||||
|
||||
ls.add_snippets("markdown", {
|
||||
s("date", {
|
||||
d(1, date_input, {}, { user_args = { "%Y-%m-%d" } }),
|
||||
}),
|
||||
s("datep", {
|
||||
d(1, date_input, {}, { user_args = { "%Y-%m-%d %X %z" } }),
|
||||
}),
|
||||
s("/xrpt", {
|
||||
t("<!--more-->"),
|
||||
}),
|
||||
s("bb", {
|
||||
t({ "**" }),
|
||||
i(1),
|
||||
t({ "**" }),
|
||||
}),
|
||||
s("ii", {
|
||||
t({ "*" }),
|
||||
i(1),
|
||||
t({ "*" }),
|
||||
}),
|
||||
})
|
10
.config/nvim/lua/plugin/lsp/html.lua
Normal file
10
.config/nvim/lua/plugin/lsp/html.lua
Normal file
@ -0,0 +1,10 @@
|
||||
-- Author : swytch
|
||||
-- Created : Sunday Feb. 19, 2023 17:09:46 CET
|
||||
-- License : GPLv3
|
||||
-- Description : neovim lsp config file for html-lsp
|
||||
|
||||
local M = {}
|
||||
|
||||
M.setup = function(opts) end
|
||||
|
||||
return M
|
@ -11,6 +11,8 @@ local servers = {
|
||||
"rust_analyzer",
|
||||
"lua_ls",
|
||||
"texlab",
|
||||
"tsserver",
|
||||
"html",
|
||||
}
|
||||
|
||||
return {
|
||||
|
11
.config/nvim/lua/plugin/lsp/tsserver.lua
Normal file
11
.config/nvim/lua/plugin/lsp/tsserver.lua
Normal file
@ -0,0 +1,11 @@
|
||||
-- Author : swytch
|
||||
-- Created : Sunday Feb. 19, 2023 17:12:35 CET
|
||||
-- License : GPLv3
|
||||
-- Description : neovim lsp config file for tsserver
|
||||
|
||||
|
||||
local M = {}
|
||||
|
||||
M.setup = function(opts) end
|
||||
|
||||
return M
|
@ -13,6 +13,7 @@ return {
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"c", "cpp", "lua", "rust", "bash", "vim", "latex", "python",
|
||||
"html", "javascript", "json", "markdown"
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
@ -63,3 +63,8 @@ utils.create_augroup({
|
||||
{"BufNewFile,BufRead", "*.mom", "set filetype=groff"},
|
||||
{"BufNewFile,BufRead", "*.tex", "set filetype=tex"},
|
||||
}, "enforce_filetypes")
|
||||
|
||||
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
||||
pattern = {"*.njk"},
|
||||
callback = function() vim.bo.filetype="html" end,
|
||||
})
|
||||
|
Reference in New Issue
Block a user