Skip to content

Commit

Permalink
feat: import nvim from main
Browse files Browse the repository at this point in the history
  • Loading branch information
wroyca committed Sep 2, 2024
1 parent 81cfe04 commit 7e3ba34
Show file tree
Hide file tree
Showing 156 changed files with 17,338 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dot_config/nvim/after/ftplugin/c.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vim.opt_local.path = "/usr/include/**,/usr/local/include/**,/lib/clang/**"

if vim.bo.filetype ~= "c" then return end
if vim.fn.executable "clang-format" == 1 then
vim.opt_local.formatprg = "clang-format --assume-filename=.c"
end
7 changes: 7 additions & 0 deletions dot_config/nvim/after/ftplugin/cpp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if vim.bo.filetype ~= "cpp" then return end
if vim.fn.executable "clang-format" == 1 then
vim.opt_local.formatprg = "clang-format --assume-filename=.cpp"
end

vim.bo.commentstring = '// %s'
vim.opt_local.cinkeys:remove ":"
4 changes: 4 additions & 0 deletions dot_config/nvim/after/ftplugin/gitcommit.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if vim.bo.filetype ~= "gitcommit" then return end

vim.opt_local.textwidth = 72
vim.opt_local.formatoptions:remove({ "c", "r", "o", "q" })
4 changes: 4 additions & 0 deletions dot_config/nvim/after/ftplugin/gitconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if vim.bo.filetype ~= "gitconfig" then return end

vim.opt_local.comments = ":#"
vim.opt_local.commentstring = "# %s"
21 changes: 21 additions & 0 deletions dot_config/nvim/after/ftplugin/help.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if vim.bo.filetype ~= "help" then return end
vim.api.nvim_create_autocmd("BufWinEnter", {
callback = function(event)
if vim.bo.filetype == "help" then
vim.bo[event.buf].buflisted = true
vim.bo[event.buf].modifiable = true
vim.bo[event.buf].readonly = false
vim.api.nvim_exec2("wincmd L", {})
end
end
})

vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
if vim.bo.filetype == "help" then
local file_path = vim.fn.expand("%:p")
-- Async (vim.system) doesn't play well with expand.
vim.fn.system("chezmoi re-add " .. file_path)
end
end
})
4 changes: 4 additions & 0 deletions dot_config/nvim/after/ftplugin/json.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if vim.bo.filetype ~= "json" then return end
if vim.fn.executable "clang-format" == 1 then
vim.opt_local.formatprg = "clang-format --assume-filename=.json"
end
59 changes: 59 additions & 0 deletions dot_config/nvim/after/ftplugin/lua.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
if vim.bo.filetype ~= "lua" then return end
if vim.fn.executable "stylua" == 1 then
vim.opt_local.formatprg = "stylua -"
end
vim.bo.comments = ":---,:--"

vim.b.miniai_config = {
custom_textobjects = {
s = {
"%[%[().-()%]%]",
},
},
}

vim.b.minisurround_config = {
custom_surroundings = {
s = {
input = {
"%[%[().-()%]%]",
},
output = {
left = "[[",
right = "]]",
},
},
},
}

if _G.MiniSplitjoin ~= nil then
local gen_hook = MiniSplitjoin.gen_hook
local curly = {
brackets = {
"%b{}",
},
}

-- Add trailing comma when splitting inside curly brackets
local add_comma_curly = gen_hook.add_trailing_separator(curly)

-- Delete trailing comma when joining inside curly brackets
local del_comma_curly = gen_hook.del_trailing_separator(curly)

-- Pad curly brackets with single space after join
local pad_curly = gen_hook.pad_brackets(curly)

vim.b.minisplitjoin_config = {
split = {
hooks_post = {
add_comma_curly,
},
},
join = {
hooks_post = {
del_comma_curly,
pad_curly,
},
},
}
end
10 changes: 10 additions & 0 deletions dot_config/nvim/after/ftplugin/man.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if vim.bo.filetype ~= "man" then return end
vim.api.nvim_create_autocmd("BufWinEnter", {
callback = function(event)
if vim.bo.filetype == "man" then
vim.bo[event.buf].buflisted = false
vim.api.nvim_exec2("wincmd L", {})
vim.keymap.set("n", "q", "<cmd>q<cr>", { buffer = event.buf, silent = true })
end
end,
})
Loading

0 comments on commit 7e3ba34

Please sign in to comment.