Skip to content

Commit

Permalink
refactor(nvim): move file type related options to ftplugin
Browse files Browse the repository at this point in the history
  • Loading branch information
schardev committed Aug 4, 2024
1 parent b211b67 commit 31cdc63
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
2 changes: 2 additions & 0 deletions config/nvim/after/ftplugin/javascript.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vim.wo.spell = true
vim.opt_local.spelloptions:append("camel")
6 changes: 6 additions & 0 deletions config/nvim/after/ftplugin/javascriptreact.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Source javascript ftplugin
vim.cmd("runtime! ftplugin/javascript.lua")

-- React directives
vim.cmd.inoreabbrev("uc", '"use client";')
vim.cmd.inoreabbrev("us", '"use server";')
2 changes: 2 additions & 0 deletions config/nvim/after/ftplugin/typescript.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Source javascript ftplugin
vim.cmd("runtime! ftplugin/javascript.lua")
3 changes: 3 additions & 0 deletions config/nvim/after/ftplugin/typescriptreact.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Source typescript and jsx ftplugin
vim.cmd("runtime! ftplugin/typescript.lua")
vim.cmd("runtime! ftplugin/javascriptreact.lua")
16 changes: 0 additions & 16 deletions config/nvim/lua/core/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,3 @@ autocmd("TextYankPost", {
end,
desc = "Highlight text on yank (copy)",
})

autocmd("FileType", {
group = my_local_group,
pattern = { "javascript", "typescript", "javascriptreact", "typescriptreact" },
callback = function()
vim.opt_local.spell = true

-- When a word is CamelCased, assume "Cased" is a separate word
vim.opt_local.spelloptions:append("camel")

-- React directives
vim.cmd.inoreabbrev("uc", '"use client";')
vim.cmd.inoreabbrev("us", '"use server";')
end,
desc = "ECMA specific file settings",
})

0 comments on commit 31cdc63

Please sign in to comment.