Compare commits
4 Commits
181e959337
...
23511bdbe6
Author | SHA1 | Date |
---|---|---|
Enrique MP | 23511bdbe6 | |
Enrique MP | f80659fd65 | |
Enrique MP | ce49a449d1 | |
Enrique MP | 65ac1d0823 |
|
@ -29,3 +29,21 @@ au({ "BufRead", "BufNewFile" }, {
|
|||
vim.opt_local.spelllang = "en,es"
|
||||
end,
|
||||
})
|
||||
|
||||
-- go to last loc when opening a buffer
|
||||
local LastLoc = ag("last_loc", { clear = true })
|
||||
au("BufReadPost", {
|
||||
group = LastLoc,
|
||||
callback = function(event)
|
||||
local exclude = { "gitcommit" }
|
||||
local buf = event.buf
|
||||
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then
|
||||
return
|
||||
end
|
||||
local mark = vim.api.nvim_buf_get_mark(buf, '"')
|
||||
local lcount = vim.api.nvim_buf_line_count(buf)
|
||||
if mark[1] > 0 and mark[1] <= lcount then
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = true -- runs require('Comment').setup()
|
||||
dependencies = {
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
},
|
||||
-- config = true, -- runs require('Comment').setup()
|
||||
config = function()
|
||||
-- import comment plugin safely
|
||||
local comment = require("Comment")
|
||||
|
||||
local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim")
|
||||
|
||||
-- enable comment
|
||||
comment.setup({
|
||||
-- for commenting tsx and jsx files
|
||||
pre_hook = ts_context_commentstring.create_pre_hook(),
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ return {
|
|||
formatters_by_ft = {
|
||||
javascript = { "prettier" },
|
||||
typescript = { "prettier" },
|
||||
svelte = { "prettier" },
|
||||
css = { "prettier" },
|
||||
html = { "prettier" },
|
||||
json = { "prettier" },
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
main = "ibl",
|
||||
opts = {},
|
||||
}
|
|
@ -9,6 +9,7 @@ return {
|
|||
javascript = { "eslint_d" },
|
||||
typescript = { "eslint_d" },
|
||||
python = { "pylint" },
|
||||
svelte = { "eslint_d" },
|
||||
markdown = { "markownlint" },
|
||||
sh = { "shellcheck" },
|
||||
}
|
||||
|
|
|
@ -20,43 +20,43 @@ return {
|
|||
|
||||
-- set keymaps
|
||||
opts.desc = "Show LSP references"
|
||||
map.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
|
||||
map.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts, { desc = "show definition, references" })
|
||||
|
||||
opts.desc = "Go to declaration"
|
||||
map.set("n", "gD", "vim.lsp.buf.declaration", opts) -- go to declaration
|
||||
map.set("n", "gD", "vim.lsp.buf.declaration", opts, { desc = "go to declaration" })
|
||||
|
||||
opts.desc = "Show LSP definitions"
|
||||
map.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
|
||||
map.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts, { desc = "show lsp definitions" })
|
||||
|
||||
opts.desc = "Show LSP implementations"
|
||||
map.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
|
||||
map.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts, { desc = "show lsp implementations" })
|
||||
|
||||
opts.desc = "Show LSP type definitions"
|
||||
map.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type implementations
|
||||
map.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts, { desc = "show lsp type implementations" })
|
||||
|
||||
opts.desc = "See available code actions"
|
||||
map.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
|
||||
map.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts, { desc = "see available code actions" })
|
||||
|
||||
opts.desc = "Smart rename"
|
||||
map.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
|
||||
map.set("n", "<leader>rn", vim.lsp.buf.rename, opts, { desc = "smart rename" })
|
||||
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
map.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
|
||||
map.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts, { desc = "show diagnostics for file" })
|
||||
|
||||
opts.desc = "Show line diagnostics"
|
||||
map.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
|
||||
map.set("n", "<leader>d", vim.diagnostic.open_float, opts, { desc = "show diagnostics for line" })
|
||||
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
map.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to prev diagnostic in buffer
|
||||
map.set("n", "[d", vim.diagnostic.goto_prev, opts, { desc = "jump to prev diagnostic in buffer" })
|
||||
|
||||
opts.desc = "Go to next diagnostic"
|
||||
map.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
|
||||
map.set("n", "]d", vim.diagnostic.goto_next, opts, { desc = "jump to next diagnostic in buffer" })
|
||||
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
map.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
|
||||
map.set("n", "K", vim.lsp.buf.hover, opts, { desc = "show documentation for what is under cursor" })
|
||||
|
||||
opts.desc = "Restart LSP"
|
||||
map.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
|
||||
map.set("n", "<leader>rs", ":LspRestart<CR>", opts, { desc = "mapping to restart lsp if necessary" })
|
||||
end
|
||||
|
||||
-- used to enable autocompletion (assign to every lsp server config)
|
||||
|
@ -126,5 +126,20 @@ return {
|
|||
},
|
||||
},
|
||||
})
|
||||
lspconfig["svelte"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = { "*.js", "*.ts" },
|
||||
callback = function(ctx)
|
||||
if client.name == "svelte" then
|
||||
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ return {
|
|||
"cssls",
|
||||
"lua_ls",
|
||||
"emmet_ls",
|
||||
"svelte",
|
||||
"pyright",
|
||||
},
|
||||
-- auto-install configured servers (with lspconfig)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
return {
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
config = function()
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
end,
|
||||
},
|
||||
opts = {
|
||||
history = true,
|
||||
delete_check_events = "TextChanged",
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
|
||||
vim.keymap.set({"i"}, "<C-K>", function() require("luasnip").expand() end, {silent = true}),
|
||||
vim.keymap.set({"i", "s"}, "<C-L>", function() require("luasnip").jump(1) end, {silent = true}),
|
||||
vim.keymap.set({"i", "s"}, "<C-J>", function() require("luasnip").jump(-1) end, {silent = true}),
|
||||
vim.keymap.set({"i", "s"}, "<C-E>", function()
|
||||
if require("luasnip").choice_active() then
|
||||
require("luasnip").change_choice(1)
|
||||
end
|
||||
end, {silent = true})
|
||||
-- {
|
||||
-- "<tab>",
|
||||
-- function ()
|
||||
-- return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab"
|
||||
-- end,
|
||||
-- expr = true, silent = true, mode = "i",
|
||||
-- },
|
||||
-- { "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
|
||||
-- { "<s-tab>", function() require("luasnip").jump(-1) end, mode = {"i", "s" }},
|
||||
},
|
||||
}
|
|
@ -33,6 +33,7 @@ return {
|
|||
"yaml",
|
||||
"html",
|
||||
"css",
|
||||
"svelte",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"bash",
|
||||
|
|
Loading…
Reference in New Issue