Moves to snacks picker
and adapts blink keybindings
This commit is contained in:
parent
31dc7d2f55
commit
26428924c0
7 changed files with 54 additions and 313 deletions
|
|
@ -2,3 +2,21 @@ vim.lsp.enable("ts_ls")
|
|||
vim.lsp.enable("lua_ls")
|
||||
vim.lsp.enable("eslint")
|
||||
vim.lsp.enable("jsonls")
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
severity_sort = false,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local opts = { buffer = args.buf }
|
||||
|
||||
vim.keymap.set("n", "<C-Space>", "<C-x><C-o>", opts)
|
||||
vim.keymap.set("n", "<Space>e", "vim.diagnostic.open_float()", opts)
|
||||
vim.keymap.set("n", "<Space>ca", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,12 @@ return {
|
|||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
keymap = { preset = "enter" }, -- 'default' | 'super-tab' | 'enter'
|
||||
keymap = {
|
||||
preset = "enter",
|
||||
["<Tab>"] = { "select_next", "fallback" },
|
||||
["<S-Tab>"] = { "select_prev", "fallback" },
|
||||
["<C-k>"] = { "show_documentation", "hide_documentation" },
|
||||
},
|
||||
appearance = {
|
||||
nerd_font_variant = "mono",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
return {
|
||||
"ibhagwan/fzf-lua",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
opts = {},
|
||||
}
|
||||
|
|
@ -1,276 +0,0 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
version = "0.1.9",
|
||||
dependencies = {
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"b0o/schemastore.nvim",
|
||||
},
|
||||
config = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
local luasnip = require("luasnip")
|
||||
local dnscUtils = require("dnsc.utils")
|
||||
local lspUtils = require("lspconfig.util")
|
||||
local cmp = require("cmp")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local servers = {
|
||||
"eslint",
|
||||
"angularls",
|
||||
"ts_ls",
|
||||
"lua_ls",
|
||||
"jsonls",
|
||||
"html",
|
||||
"cssls",
|
||||
"tailwindcss",
|
||||
"gopls",
|
||||
"astro",
|
||||
"tinymist",
|
||||
"ols",
|
||||
}
|
||||
|
||||
require("mason").setup()
|
||||
-- Automatic Server Installation with Mason
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = servers,
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
-- LANGUAGE SERVERS
|
||||
-- Lua
|
||||
lspconfig.lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Typescript
|
||||
lspconfig.tsserver.setup({
|
||||
capabilities = capabilities,
|
||||
root_dir = lspUtils.root_pattern("package.json"),
|
||||
init_options = {
|
||||
preferences = {
|
||||
importModuleSpecifierPreference = "relative",
|
||||
importModuleSpecifierEnding = "minimal",
|
||||
},
|
||||
},
|
||||
handlers = {
|
||||
["textDocument/definition"] = function(err, result, method, ...)
|
||||
if vim.tbl_islist(result) and #result > 1 then
|
||||
local filtered_result = dnscUtils.filter(result, dnscUtils.filterReactDTS)
|
||||
return vim.lsp.handlers["textDocument/definition"](err, filtered_result, method, ...)
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/definition"](err, result, method, ...)
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- JSON
|
||||
lspconfig.jsonls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
validate = { enable = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- HTML
|
||||
lspconfig.html.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- Astro
|
||||
lspconfig.astro.setup({})
|
||||
|
||||
-- Tailwind
|
||||
lspconfig.tailwindcss.setup({})
|
||||
|
||||
-- Typst
|
||||
lspconfig.tinymist.setup({
|
||||
single_file_support = true,
|
||||
root_dir = function()
|
||||
return vim.fn.getcwd()
|
||||
end,
|
||||
settings = {},
|
||||
})
|
||||
|
||||
-- CSS
|
||||
lspconfig.cssls.setup({})
|
||||
|
||||
-- Angular
|
||||
lspconfig.angularls.setup({})
|
||||
|
||||
-- ESLint
|
||||
lspconfig.eslint.setup({})
|
||||
|
||||
-- Go
|
||||
lspconfig.gopls.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- Run gofmt + goimports on save
|
||||
local format_sync_grp = vim.api.nvim_create_augroup("goimports", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.go",
|
||||
callback = function()
|
||||
require("go.format").goimports()
|
||||
end,
|
||||
group = format_sync_grp,
|
||||
})
|
||||
|
||||
-- Odin
|
||||
lspconfig.ols.setup({})
|
||||
|
||||
-- LSP Keybindings
|
||||
-- Global mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist)
|
||||
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format("%s ", vim_item.kind) -- This concatenates the icons with the name of the item kind
|
||||
-- Source
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snip]",
|
||||
nvim_lua = "[Lua]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
if luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
else
|
||||
cmp.confirm({
|
||||
select = true,
|
||||
})
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp", keyword_length = 1 },
|
||||
{ name = "path" },
|
||||
{ name = "buffer", keyword_length = 3 },
|
||||
{ name = "luasnip" }, -- For luasnip users.
|
||||
{ name = "render-markdown" },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ "/", "?" }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Set up vim-dadbod completions
|
||||
cmp.setup.filetype({ "sql", "mysql", "psql" }, {
|
||||
sources = {
|
||||
{ name = "vim-dadbod-completion" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Set up org mode
|
||||
cmp.setup.filetype({ "org" }, {
|
||||
sources = {
|
||||
{ name = "orgmode" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -26,6 +26,12 @@ return {
|
|||
enabled = true,
|
||||
configure = true,
|
||||
},
|
||||
picker = {
|
||||
enabled = true,
|
||||
prompt = "λ ",
|
||||
preset = "ivy",
|
||||
layout = { position = "bottom" },
|
||||
},
|
||||
statuscolumn = { enabled = true },
|
||||
zen = { enabled = true },
|
||||
},
|
||||
|
|
@ -36,6 +42,26 @@ return {
|
|||
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Show git blame for current line" },
|
||||
{ "<leader>gl", function() Snacks.gitbrowse() end, desc = "Open link to line at git remote" },
|
||||
-- Zen Mode
|
||||
{ "<leader>z", function() Snacks.zen() end, desc = "Toggle Zen Mode" }
|
||||
{ "<leader>z", function() Snacks.zen() end, desc = "Toggle Zen Mode" },
|
||||
-- Picker
|
||||
{ "<leader>", function() end, desc = "" },
|
||||
{ "<leader>.", function() Snacks.picker.files() end, desc = "" },
|
||||
{ "<leader><leader>", function() Snacks.picker.git_files() end, desc = "Git files" },
|
||||
-- Find
|
||||
{ "<leader>fr", function() Snacks.picker.recent() end, desc = "Recent" },
|
||||
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
|
||||
-- Search
|
||||
{ "<leader>ss", function() Snacks.picker.grep() end, desc = "Grep" },
|
||||
{ "<leader>sw", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } },
|
||||
{ "<leader>su", function() Snacks.picker.undo() end, desc = "Undo History" },
|
||||
-- Diagnostics
|
||||
{ "<leader>td", function() Snacks.picker.diagnostics_buffer() end, desc = "Buffer Diagnostics" },
|
||||
{ "<leader>ta", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" },
|
||||
-- LSP
|
||||
{ "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition" },
|
||||
{ "gD", function() Snacks.picker.lsp_declarations() end, desc = "Goto Declaration" },
|
||||
{ "grr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" },
|
||||
{ "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" },
|
||||
{ "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" },
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,7 @@ return {
|
|||
{ "<leader>o", group = "open", mode = "n" },
|
||||
{ "<leader>ot", ":e ~/notes/todo.txt<cr>", desc = "Open todos", mode = "n" },
|
||||
{ "<leader>od", ":80 vsplit | :VimwikiMakeDiaryNote<cr>", desc = "Open diary note in split", mode = "n" },
|
||||
{ "<leader>.", "<cmd>FzfLua files<cr>", desc = "Find file in dir", mode = "n" },
|
||||
{ "<leader><leader>", "<cmd>FzfLua git_files<cr>", desc = "Find git file", mode = "n" },
|
||||
{ "<leader>B", "<cmd>FzfLua buffers<cr>", desc = "Opens buffers", mode = "n" },
|
||||
{ "<leader>b", group = "buffer", mode = "n" },
|
||||
{ "<leader>bb", "<cmd>FzfLua buffers<cr>", desc = "Switches buffers", mode = "n" },
|
||||
{ "<leader>b,", "<Cmd>BufferMovePrevious<CR>", desc = "Move buffer back", mode = "n" },
|
||||
{
|
||||
"<leader>b.",
|
||||
|
|
@ -62,14 +58,6 @@ return {
|
|||
desc = "Run current project",
|
||||
mode = "n",
|
||||
},
|
||||
{ "<leader>ca", "<cmd>FzfLua lsp_code_actions<cr>", desc = "Code actions", mode = "n" },
|
||||
{ "<leader>cd", "<cmd>FzfLua diagnostics_document<cr>", desc = "Show diagnostics", mode = "n" },
|
||||
{
|
||||
"<leader>cf",
|
||||
"<cmd>FzfLua lsp_references<cr>",
|
||||
desc = "Show references",
|
||||
mode = "n",
|
||||
},
|
||||
{
|
||||
"<leader>q",
|
||||
"<cmd>wq<cr>",
|
||||
|
|
@ -83,7 +71,6 @@ return {
|
|||
desc = "Create a new file",
|
||||
mode = "n",
|
||||
},
|
||||
{ "<leader>fr", "<cmd>FzfLua oldfiles<cr>", desc = "Open Recent File", mode = "n" },
|
||||
{
|
||||
"<leader>fs",
|
||||
"<cmd>w<cr>",
|
||||
|
|
@ -92,21 +79,7 @@ return {
|
|||
},
|
||||
{ "<leader>q", "<cmd>qa!<cr>", desc = "Leave neovim", mode = "n" },
|
||||
{ "<leader>s", group = "search", mode = "n" },
|
||||
{ "<leader>ss", "<cmd>FzfLua live_grep_native<CR>", desc = "Live Grep", mode = "n" },
|
||||
{ "<leader>sp", "<cmd>FzfLua grep_project<CR>", desc = "Grep in project", mode = "n" },
|
||||
{
|
||||
"<leader>sw",
|
||||
"<cmd>FzfLua grep_cword<cr>",
|
||||
desc = "Search current word",
|
||||
mode = "n",
|
||||
},
|
||||
{ "<leader>t", group = "diagnostics (lsp)", mode = "n" },
|
||||
{
|
||||
"<leader>td",
|
||||
"<cmd>FzfLua diagnostics_document<cr>",
|
||||
desc = "Show LSP diagnostics",
|
||||
mode = "n",
|
||||
},
|
||||
{ "<leader>ta", "<cmd>TodoQuickFix<cr>", desc = "Show all todo comments", mode = "n" },
|
||||
{ "<leader>w", group = "window", mode = "n" },
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue