init
This commit is contained in:
16
nvim/after/ftplugin/javascriptreact.lua
Normal file
16
nvim/after/ftplugin/javascriptreact.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Automatically end a self-closing tag when pressing /
|
||||
vim.keymap.set("i", "/", function()
|
||||
local node = vim.treesitter.get_node()
|
||||
if not node then
|
||||
return "/"
|
||||
end
|
||||
|
||||
if node:type() == "jsx_opening_element" then
|
||||
local char_at_cursor = vim.fn.strcharpart(vim.fn.strpart(vim.fn.getline("."), vim.fn.col(".") - 2), 0, 1)
|
||||
local already_have_space = char_at_cursor == " "
|
||||
|
||||
return already_have_space and "/>" or " />"
|
||||
end
|
||||
|
||||
return "/"
|
||||
end, { expr = true, buffer = true })
|
||||
11
nvim/after/ftplugin/json.lua
Normal file
11
nvim/after/ftplugin/json.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
-- When creating a new line with o, make sure there is a trailing comma on the current line
|
||||
vim.keymap.set("n", "o", function()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
|
||||
local should_add_comma = string.find(line, "[^,{[]$")
|
||||
if should_add_comma then
|
||||
return "A,<cr>"
|
||||
else
|
||||
return "o"
|
||||
end
|
||||
end, { buffer = true, expr = true })
|
||||
11
nvim/after/ftplugin/jsonc.lua
Normal file
11
nvim/after/ftplugin/jsonc.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
-- When creating a new line with o, make sure there is a trailing comma on the current line
|
||||
vim.keymap.set("n", "o", function()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
|
||||
local should_add_comma = string.find(line, "[^,{[]$")
|
||||
if should_add_comma then
|
||||
return "A,<cr>"
|
||||
else
|
||||
return "o"
|
||||
end
|
||||
end, { buffer = true, expr = true })
|
||||
11
nvim/after/ftplugin/markdown.lua
Normal file
11
nvim/after/ftplugin/markdown.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
vim.keymap.set({ "n", "x" }, "]#", [[/^#\+ .*<CR>]], { desc = "Next Heading", buffer = true })
|
||||
vim.keymap.set({ "n", "x" }, "[#", [[?^#\+ .*<CR>]], { desc = "Prev Heading", buffer = true })
|
||||
|
||||
-- stylua: ignore start
|
||||
if LazyVim.has("markdowny.nvim") then
|
||||
vim.keymap.set("v", "<C-b>", function() require('markdowny').bold() end, { buffer = 0 })
|
||||
vim.keymap.set("v", "<C-i>", function() require('markdowny').italic() end, { buffer = 0 })
|
||||
vim.keymap.set("v", "<C-k>", function() require('markdowny').link() end, { buffer = 0 })
|
||||
vim.keymap.set("v", "<C-e>", function() require('markdowny').code() end, { buffer = 0 })
|
||||
end
|
||||
-- stylua: ignore end
|
||||
16
nvim/after/ftplugin/typescriptreact.lua
Normal file
16
nvim/after/ftplugin/typescriptreact.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Automatically end a self-closing tag when pressing /
|
||||
vim.keymap.set("i", "/", function()
|
||||
local node = vim.treesitter.get_node()
|
||||
if not node then
|
||||
return "/"
|
||||
end
|
||||
|
||||
if node:type() == "jsx_opening_element" then
|
||||
local char_at_cursor = vim.fn.strcharpart(vim.fn.strpart(vim.fn.getline("."), vim.fn.col(".") - 2), 0, 1)
|
||||
local already_have_space = char_at_cursor == " "
|
||||
|
||||
return already_have_space and "/>" or " />"
|
||||
end
|
||||
|
||||
return "/"
|
||||
end, { expr = true, buffer = true })
|
||||
Reference in New Issue
Block a user