feat: add rename func; format files

This commit is contained in:
Devin Haska 2024-04-29 08:58:14 -07:00
parent 7afc4aab72
commit 8f87ddde79
6 changed files with 145 additions and 144 deletions

View file

@ -1,14 +1,14 @@
local function augroup(name) local function augroup(name)
return vim.api.nvim_create_augroup("wf_" .. name, { clear = true }) return vim.api.nvim_create_augroup("wf_" .. name, { clear = true })
end end
vim.api.nvim_create_autocmd({ "FileType" }, { vim.api.nvim_create_autocmd({ "FileType" }, {
group = augroup("spellcheck"), group = augroup("spellcheck"),
pattern = { "gitcommit", "markdown", "md", "mdx" }, pattern = { "gitcommit", "markdown", "md", "mdx" },
callback = function() callback = function()
vim.opt_local.spell = true vim.opt_local.spell = true
vim.opt_local.wrap = true vim.opt_local.wrap = true
end, end,
}) })
-- vim.api.nvim_create_autocmd({ "FileType" }, { -- vim.api.nvim_create_autocmd({ "FileType" }, {

View file

@ -1,96 +1,96 @@
return { return {
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-nvim-lsp" }, dependencies = { "hrsh7th/cmp-nvim-lsp" },
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup({ cmp.setup({
-- Highlights the first result always -- Highlights the first result always
completion = { completion = {
completeopt = "menu,menuone,noinsert", completeopt = "menu,menuone,noinsert",
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-o>"] = cmp.mapping.complete(), ["<C-o>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
else else
fallback() fallback()
end end
end, { "i" }), end, { "i" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
else else
fallback() fallback()
end end
end, { "i" }), end, { "i" }),
["<CR>"] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm({
behaviour = cmp.ConfirmBehavior.Insert, behaviour = cmp.ConfirmBehavior.Insert,
select = true, select = true,
}), }),
}), }),
snippet = { snippet = {
expand = function(args) expand = function(args)
require("luasnip").lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end, end,
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
}, { }, {
{ name = "buffer" }, { name = "buffer" },
}), }),
}) })
end, end,
}, },
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
dependencies = { "rafamadriz/friendly-snippets" }, dependencies = { "rafamadriz/friendly-snippets" },
}, },
{ {
"echasnovski/mini.pairs", "echasnovski/mini.pairs",
version = false, version = false,
opts = {}, opts = {},
}, },
{ {
"echasnovski/mini.surround", "echasnovski/mini.surround",
version = false, version = false,
opts = { opts = {
mappings = { mappings = {
add = "gsa", -- Add surrounding in Normal and Visual modes add = "gsa", -- Add surrounding in Normal and Visual modes
delete = "gsd", -- Delete surrounding delete = "gsd", -- Delete surrounding
find = "gsf", -- Find surrounding (to the right) find = "gsf", -- Find surrounding (to the right)
find_left = "gsF", -- Find surrounding (to the left) find_left = "gsF", -- Find surrounding (to the left)
highlight = "gsh", -- Highlight surrounding highlight = "gsh", -- Highlight surrounding
replace = "gsr", -- Replace surrounding replace = "gsr", -- Replace surrounding
update_n_lines = "gsn", -- Update `n_lines` update_n_lines = "gsn", -- Update `n_lines`
}, },
}, },
}, },
{ {
"JoosepAlviste/nvim-ts-context-commentstring", "JoosepAlviste/nvim-ts-context-commentstring",
opts = { opts = {
enable_autocmd = false, enable_autocmd = false,
}, },
}, },
{ {
"echasnovski/mini.comment", "echasnovski/mini.comment",
version = false, version = false,
opts = { opts = {
options = { options = {
custom_commentstring = function() custom_commentstring = function()
return require("ts_context_commentstring.internal").calculate_commentstring() return require("ts_context_commentstring.internal").calculate_commentstring()
or vim.bo.commentstring or vim.bo.commentstring
end, end,
}, },
}, },
}, },
} }

View file

@ -1,9 +1,9 @@
return { return {
"folke/tokyonight.nvim", "folke/tokyonight.nvim",
lazy = true, lazy = true,
opts = { opts = {
style = "storm", style = "storm",
transparent = true, transparent = true,
dim_inactive = true, dim_inactive = true,
}, },
} }

View file

@ -1,20 +1,20 @@
return { return {
"stevearc/conform.nvim", "stevearc/conform.nvim",
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
css = { "prettierd" }, css = { "prettierd" },
scss = { "prettierd" }, scss = { "prettierd" },
html = { "djlint" }, html = { "djlint" },
lua = { "stylelua" }, lua = { "stylelua" },
javascript = { "prettierd" }, javascript = { "prettierd" },
javascriptreact = { "prettierd" }, javascriptreact = { "prettierd" },
json = { "prettierd" }, json = { "prettierd" },
jsonc = { "prettierd" }, jsonc = { "prettierd" },
typescript = { "prettierd" }, typescript = { "prettierd" },
typescriptreact = { "prettierd" }, typescriptreact = { "prettierd" },
}, },
format_on_save = { format_on_save = {
lsp_fallback = true, lsp_fallback = true,
}, },
}, },
} }

View file

@ -1,26 +1,26 @@
return { return {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
opts = { opts = {
events = { "BufWritePost", "BufReadPost", "InsertLeave" }, events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = { linters_by_ft = {
html = { "djlint" }, html = { "djlint" },
javascript = { "eslint_d" }, javascript = { "eslint_d" },
typescript = { "eslint_d" }, typescript = { "eslint_d" },
javascriptreact = { "eslint_d" }, javascriptreact = { "eslint_d" },
typescriptreact = { "eslint_d" }, typescriptreact = { "eslint_d" },
}, },
}, },
config = function(_, opts) config = function(_, opts)
local lint = require("lint") local lint = require("lint")
lint.linters_by_ft = opts.linters_by_ft lint.linters_by_ft = opts.linters_by_ft
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd(opts.events, { vim.api.nvim_create_autocmd(opts.events, {
group = lint_augroup, group = lint_augroup,
callback = function() callback = function()
lint.try_lint() lint.try_lint()
end, end,
}) })
end, end,
} }

View file

@ -55,6 +55,7 @@ return {
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Show signature" }) vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Show signature" })
vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, { desc = "Format buffer" }) vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, { desc = "Format buffer" })
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, { desc = "View code actions" }) vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, { desc = "View code actions" })
vim.keymap.set("n", "<leader>cr", vim.lsp.buf.rename, { desc = "Rename" })
end, end,
}, },
} }