Merge branch 'master' into changes
This commit is contained in:
commit
ef2d33bbd4
3 changed files with 502 additions and 475 deletions
199
lua/keymaps.lua
199
lua/keymaps.lua
|
@ -12,95 +12,114 @@ vim.g.maplocalleader = " "
|
|||
-- command_mode = "c",
|
||||
|
||||
require("util").keymaps({
|
||||
n = {
|
||||
[";"] = { ":", desc = "No shift command mode" },
|
||||
["n"] = { "nzzzv", desc = "Next search result centered" },
|
||||
["N"] = { "Nzzzv", desc = "Previous search result centered" },
|
||||
["<esc>"] = { ":noh<CR><esc>", desc = "Clear search on escape" },
|
||||
["<return>"] = { ":noh<CR><return>", desc = "Clear search on return" },
|
||||
["<leader>a"] = { "ggVG", desc = "Select all" },
|
||||
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
|
||||
["<leader>qq"] = { "<cmd>confirm q<cr>", desc = "Quit" },
|
||||
["<leader>bq"] = { "<cmd>bp|bd #<cr>", desc = "Close current buffer only" },
|
||||
["<leader>tn"] = { "<cmd>tabnew<cr>", desc = "Create new tab" },
|
||||
["<leader>tq"] = { "<cmd>tabclose<cr>", desc = "Close current tab" },
|
||||
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
|
||||
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
|
||||
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
|
||||
["<C-u>"] = { "<C-u>zz", desc = "Vertical half page up and center cursor" },
|
||||
["<leader>y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["<leader>p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
-- ["<leader>Q"] = { "<cmd>Neotree close<cr><cmd>qa<CR>", desc = "Quit all" },
|
||||
["<leader>q<leader>"] = { "<cmd>Neotree close<cr><cmd>qa<CR>", desc = "Quit all" },
|
||||
n = {
|
||||
[";"] = { ":", desc = "No shift command mode" },
|
||||
["n"] = { "nzzzv", desc = "Next search result centered" },
|
||||
["N"] = { "Nzzzv", desc = "Previous search result centered" },
|
||||
["<esc>"] = { ":noh<CR><esc>", desc = "Clear search on escape" },
|
||||
["<return>"] = { ":noh<CR><return>", desc = "Clear search on return" },
|
||||
["<leader>a"] = { "ggVG", desc = "Select all" },
|
||||
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
|
||||
["<leader>qq"] = {
|
||||
function()
|
||||
-- Use to have this which always closed and quit ont he last screen: "<cmd>confirm q<cr>"
|
||||
-- Instead I want this behavior:
|
||||
-- if only 1 screen is open then close all buffers, resulting in a blank unamed buffer window similar to fresh session
|
||||
-- else if more than 1 screen, confirm q to close that screen
|
||||
-- Check the number of screens
|
||||
if vim.fn.winnr("$") == 1 then
|
||||
-- If only 1 screen is open then close all buffers, resulting in a blank unnamed buffer window similar to fresh session
|
||||
vim.cmd("bufdo bd")
|
||||
vim.cmd("SessionDelete")
|
||||
else
|
||||
-- If more than 1 screen, confirm q to close that screen
|
||||
vim.cmd("confirm q")
|
||||
end
|
||||
end,
|
||||
desc = "Quit",
|
||||
},
|
||||
["<leader>bq"] = { "<cmd>bp|bd #<cr>", desc = "Close current buffer only" },
|
||||
["<leader>tn"] = { "<cmd>tabnew<cr>", desc = "Create new tab" },
|
||||
["<leader>tq"] = { "<cmd>tabclose<cr>", desc = "Close current tab" },
|
||||
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
|
||||
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
|
||||
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
|
||||
["<C-u>"] = { "<C-u>zz", desc = "Vertical half page up and center cursor" },
|
||||
["<leader>y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["<leader>p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
-- ["<leader>Q"] = { "<cmd>Neotree close<cr><cmd>qa<CR>", desc = "Quit all" },
|
||||
["<leader>qq<leader>"] = { "<cmd>Neotree close<cr><cmd>SessionDelete<cr><cmd>qa<CR>", desc = "Quit all, no session saved" },
|
||||
["J"] = { "mzJ`z", desc = "Move line below onto this line" },
|
||||
["<S-Tab>"] = { "<C-o>", desc = "Go back <C-o>" },
|
||||
-- window navigation
|
||||
["<C-h>"] = { "<C-w>h", desc = "Move window left current" },
|
||||
["<C-j>"] = { "<C-w>j", desc = "Move window below current" },
|
||||
["<C-k>"] = { "<C-w>k", desc = "Move window above current" },
|
||||
["<C-l>"] = { "<C-w>l", desc = "Move window right current" },
|
||||
-- tab navigation
|
||||
["H"] = { "<cmd>tabprevious<cr>", desc = "Move to previous tab" },
|
||||
["L"] = { "<cmd>tabnext<cr>", desc = "Move to next tab" },
|
||||
-- reformat LSP
|
||||
["<leader>l<leader>"] = {
|
||||
function()
|
||||
-- vim.cmd "SqlxFormat"
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
desc = "Reformat file",
|
||||
},
|
||||
["<leader>ls<leader>"] = { "<cmd>SqlxFormat<cr>", desc = "Format sqlx queries in rust raw string literals." },
|
||||
["<leader>ld"] = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Show diagnostic message",
|
||||
},
|
||||
["<leader>ll"] = {
|
||||
function()
|
||||
vim.diagnostic.setloclist()
|
||||
end,
|
||||
desc = "Show diagnostic list",
|
||||
},
|
||||
["<leader>lz"] = { "<cmd>e<CR>", desc = "Edit current file again / Restart LSP Server" },
|
||||
["<leader>,uu"] = { ':let @u = trim(tolower(system("uuidgen")))<cr>a<C-r>u', desc = "Generate and insert UUID" },
|
||||
["B"] = { "<cmd>b#<cr>", desc = "Switch to last buffer" },
|
||||
["<leader>S"] = {
|
||||
"<cmd>set equalalways<cr><cmd>set noequalalways<cr>",
|
||||
desc = "Equalize/resize screens evenly",
|
||||
},
|
||||
},
|
||||
v = {
|
||||
["J"] = { ":m '>+1<CR>gv=gv", desc = "Visually move block down" },
|
||||
["K"] = { ":m '<-2<CR>gv=gv", desc = "Visually move block up" },
|
||||
["<leader>,uu"] = {
|
||||
'd:let @u = trim(tolower(system("uuidgen")))<cr>i<C-r>u',
|
||||
desc = "Generate and replace UUID",
|
||||
},
|
||||
["<leader>y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["<leader>p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
["p"] = { '"_dP', desc = "Paste without yanking replaced content" },
|
||||
["<C-r>"] = { '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection" },
|
||||
},
|
||||
i = {
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
c = {
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
t = {
|
||||
["<Esc>"] = { "<C-\\><C-n>", desc = "Escape the terminal" },
|
||||
},
|
||||
["<leader>q<leader>"] = { "<cmd>Neotree close<cr><cmd>qa<CR>", desc = "Quit all" },
|
||||
["J"] = { "mzJ`z", desc = "Move line below onto this line" },
|
||||
["<S-Tab>"] = { "<C-o>", desc = "Go back <C-o>" },
|
||||
-- window navigation
|
||||
["<C-h>"] = { "<C-w>h", desc = "Move window left current" },
|
||||
["<C-j>"] = { "<C-w>j", desc = "Move window below current" },
|
||||
["<C-k>"] = { "<C-w>k", desc = "Move window above current" },
|
||||
["<C-l>"] = { "<C-w>l", desc = "Move window right current" },
|
||||
-- tab navigation
|
||||
["H"] = { "<cmd>tabprevious<cr>", desc = "Move to previous tab" },
|
||||
["L"] = { "<cmd>tabnext<cr>", desc = "Move to next tab" },
|
||||
-- reformat LSP
|
||||
["<leader>l<leader>"] = {
|
||||
function()
|
||||
-- vim.cmd "SqlxFormat"
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
desc = "Reformat file",
|
||||
},
|
||||
["<leader>ls<leader>"] = { "<cmd>SqlxFormat<cr>", desc = "Format sqlx queries in rust raw string literals." },
|
||||
["<leader>ld"] = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Show diagnostic message",
|
||||
},
|
||||
["<leader>ll"] = {
|
||||
function()
|
||||
vim.diagnostic.setloclist()
|
||||
end,
|
||||
desc = "Show diagnostic list",
|
||||
},
|
||||
["<leader>lz"] = { "<cmd>e<CR>", desc = "Edit current file again / Restart LSP Server" },
|
||||
["<leader>,uu"] = { ':let @u = trim(tolower(system("uuidgen")))<cr>a<C-r>u', desc = "Generate and insert UUID" },
|
||||
["B"] = { "<cmd>b#<cr>", desc = "Switch to last buffer" },
|
||||
["<leader>S"] = {
|
||||
"<cmd>set equalalways<cr><cmd>set noequalalways<cr>",
|
||||
desc = "Equalize/resize screens evenly",
|
||||
},
|
||||
},
|
||||
v = {
|
||||
["J"] = { ":m '>+1<CR>gv=gv", desc = "Visually move block down" },
|
||||
["K"] = { ":m '<-2<CR>gv=gv", desc = "Visually move block up" },
|
||||
["<leader>,uu"] = {
|
||||
'd:let @u = trim(tolower(system("uuidgen")))<cr>i<C-r>u',
|
||||
desc = "Generate and replace UUID",
|
||||
},
|
||||
["<leader>y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["<leader>p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
["p"] = { '"_dP', desc = "Paste without yanking replaced content" },
|
||||
["<C-r>"] = { '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection" },
|
||||
[">"] = { "> gv", desc = "Indent selection" },
|
||||
["<"] = { "< gv", desc = "Outdent selection" },
|
||||
},
|
||||
i = {
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
c = {
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
t = {
|
||||
["<Esc>"] = { "<C-\\><C-n>", desc = "Escape the terminal" },
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
local function prereqs()
|
||||
local output = vim.fn.system({
|
||||
"which",
|
||||
"rust-analyzer",
|
||||
"&&",
|
||||
"rust-analyzer",
|
||||
"--version",
|
||||
})
|
||||
if output == nil or output == "" or string.find(output, "not installed for the toolchain") then
|
||||
print("Installing rust-analyzer globally with rustup")
|
||||
vim.fn.system({
|
||||
"rustup",
|
||||
"component",
|
||||
"add",
|
||||
"rust-analyzer",
|
||||
})
|
||||
end
|
||||
local output = vim.fn.system({
|
||||
"which",
|
||||
"rust-analyzer",
|
||||
"&&",
|
||||
"rust-analyzer",
|
||||
"--version",
|
||||
})
|
||||
if output == nil or output == "" or string.find(output, "not installed for the toolchain") then
|
||||
print("Installing rust-analyzer globally with rustup")
|
||||
vim.fn.system({
|
||||
"rustup",
|
||||
"component",
|
||||
"add",
|
||||
"rust-analyzer",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local servers = {
|
||||
-- rust_analyzer = USES RUST_TOOLS INSTEAD, SEE BOTTOM OF THIS FILE
|
||||
tsserver = {
|
||||
-- typescript/javascript
|
||||
},
|
||||
pyright = {
|
||||
-- python
|
||||
},
|
||||
lua_ls = {
|
||||
-- lua
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) },
|
||||
telemetry = { enable = false },
|
||||
diagnostics = {
|
||||
globals = {
|
||||
"vim",
|
||||
"require",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
bashls = {
|
||||
-- bash
|
||||
},
|
||||
cssls = {
|
||||
-- css
|
||||
},
|
||||
cssmodules_ls = {
|
||||
-- css modules
|
||||
},
|
||||
dockerls = {
|
||||
-- docker
|
||||
},
|
||||
docker_compose_language_service = {
|
||||
-- docker compose
|
||||
},
|
||||
jsonls = {
|
||||
-- json
|
||||
},
|
||||
marksman = {
|
||||
-- markdown
|
||||
},
|
||||
taplo = {
|
||||
-- toml
|
||||
},
|
||||
yamlls = {
|
||||
-- yaml
|
||||
},
|
||||
lemminx = {
|
||||
-- xml
|
||||
},
|
||||
rnix = {
|
||||
-- Nix
|
||||
},
|
||||
ansiblels = {
|
||||
-- ansible
|
||||
},
|
||||
-- rust_analyzer = USES RUST_TOOLS INSTEAD, SEE BOTTOM OF THIS FILE
|
||||
tsserver = {
|
||||
-- typescript/javascript
|
||||
},
|
||||
pyright = {
|
||||
-- python
|
||||
},
|
||||
lua_ls = {
|
||||
-- lua
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) },
|
||||
telemetry = { enable = false },
|
||||
diagnostics = {
|
||||
globals = {
|
||||
"vim",
|
||||
"require",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
bashls = {
|
||||
-- bash
|
||||
},
|
||||
cssls = {
|
||||
-- css
|
||||
},
|
||||
cssmodules_ls = {
|
||||
-- css modules
|
||||
},
|
||||
dockerls = {
|
||||
-- docker
|
||||
},
|
||||
docker_compose_language_service = {
|
||||
-- docker compose
|
||||
},
|
||||
jsonls = {
|
||||
-- json
|
||||
},
|
||||
marksman = {
|
||||
-- markdown
|
||||
},
|
||||
taplo = {
|
||||
-- toml
|
||||
},
|
||||
yamlls = {
|
||||
-- yaml
|
||||
},
|
||||
lemminx = {
|
||||
-- xml
|
||||
},
|
||||
rnix = {
|
||||
-- Nix
|
||||
},
|
||||
ansiblels = {
|
||||
-- ansible
|
||||
},
|
||||
}
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
update_in_insert = true,
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
update_in_insert = true,
|
||||
})
|
||||
|
||||
-- LSP config
|
||||
|
@ -90,234 +90,239 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagn
|
|||
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
local on_attach = function(client, bufnr)
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = "LSP: " .. desc
|
||||
end
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = "LSP: " .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap("<leader>lr", vim.lsp.buf.rename, "[R]ename")
|
||||
nmap("<leader>la", vim.lsp.buf.code_action, "Code [A]ction")
|
||||
local cursor_layout = {
|
||||
layout_strategy = "cursor",
|
||||
layout_config = { width = 0.25, height = 0.35 },
|
||||
}
|
||||
|
||||
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
|
||||
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
|
||||
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
|
||||
nmap("<leader>lr", vim.lsp.buf.rename, "[R]ename")
|
||||
nmap("<leader>la", vim.lsp.buf.code_action, "Code [A]ction")
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
nmap("<leader>sd", vim.lsp.buf.signature_help, "Signature Documentation")
|
||||
-- I dont like the default vim quickfix buffer opening for goto defintiion so use telescope
|
||||
-- nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
|
||||
nmap("gd", function()
|
||||
require("telescope.builtin").lsp_definitions(cursor_layout)
|
||||
end, "[G]oto [D]efinition")
|
||||
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
nmap("gI", function()
|
||||
require("telescope.builtin").lsp_implementations(cursor_layout)
|
||||
end, "[G]oto [I]mplementation")
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
-- See `:help K` for why this keymap
|
||||
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
nmap("<leader>sd", vim.lsp.buf.signature_help, "Signature Documentation")
|
||||
|
||||
-- disable tsserver so it does not conflict with prettier
|
||||
if client.name == "tsserver" then
|
||||
client.server_capabilities.document_formatting = false
|
||||
end
|
||||
-- Lesser used LSP functionality
|
||||
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
|
||||
-- disable tsserver so it does not conflict with prettier
|
||||
if client.name == "tsserver" then
|
||||
client.server_capabilities.document_formatting = false
|
||||
end
|
||||
end
|
||||
|
||||
local gen_capabilities = function(cmp)
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = cmp.default_capabilities(capabilities)
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = cmp.default_capabilities(capabilities)
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
},
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
build = "make install_jsregexp",
|
||||
opts = {
|
||||
history = true,
|
||||
region_check_events = "InsertEnter",
|
||||
delete_check_events = "TextChanged,InsertLeave",
|
||||
}
|
||||
},
|
||||
{
|
||||
-- Autocompletion
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
--"Saecki/crates.nvim", -- SEE plugins/rust-tools.lua
|
||||
"zbirenbaum/copilot-cmp",
|
||||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
cmd = {
|
||||
"Mason",
|
||||
"MasonUpdate",
|
||||
"MasonInstall",
|
||||
"MasonInstallAll",
|
||||
"MasonUninstall",
|
||||
"MasonUninstallAll",
|
||||
"MasonLog",
|
||||
},
|
||||
build = ":MasonUpdate",
|
||||
opts = {},
|
||||
},
|
||||
{ "folke/neodev.nvim", opts = {} }, -- lua stuff
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = { "nvim-telescope/telescope.nvim" },
|
||||
config = function()
|
||||
local config = require("lspconfig")
|
||||
-- local util = require("lspconfig/util")
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
{
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
},
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
build = "make install_jsregexp",
|
||||
opts = {
|
||||
history = true,
|
||||
region_check_events = "InsertEnter",
|
||||
delete_check_events = "TextChanged,InsertLeave",
|
||||
},
|
||||
},
|
||||
{
|
||||
-- Autocompletion
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
--"Saecki/crates.nvim", -- SEE plugins/rust-tools.lua
|
||||
"zbirenbaum/copilot-cmp",
|
||||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
cmd = {
|
||||
"Mason",
|
||||
"MasonUpdate",
|
||||
"MasonInstall",
|
||||
"MasonInstallAll",
|
||||
"MasonUninstall",
|
||||
"MasonUninstallAll",
|
||||
"MasonLog",
|
||||
},
|
||||
build = ":MasonUpdate",
|
||||
opts = {},
|
||||
},
|
||||
{ "folke/neodev.nvim", opts = {} }, -- lua stuff
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = { "nvim-telescope/telescope.nvim" },
|
||||
config = function()
|
||||
local config = require("lspconfig")
|
||||
-- local util = require("lspconfig/util")
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
-- LSP
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = gen_capabilities(require("cmp_nvim_lsp"))
|
||||
-- LSP
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = gen_capabilities(require("cmp_nvim_lsp"))
|
||||
|
||||
-- Install servers used
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
})
|
||||
-- Install servers used
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
})
|
||||
|
||||
local flags = {
|
||||
allow_incremental_sync = true,
|
||||
debounce_text_changes = 200,
|
||||
}
|
||||
local flags = {
|
||||
allow_incremental_sync = true,
|
||||
debounce_text_changes = 200,
|
||||
}
|
||||
|
||||
mason_lspconfig.setup_handlers({
|
||||
function(server_name)
|
||||
config[server_name].setup({
|
||||
flags = flags,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
})
|
||||
end,
|
||||
})
|
||||
mason_lspconfig.setup_handlers({
|
||||
function(server_name)
|
||||
config[server_name].setup({
|
||||
flags = flags,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Completion
|
||||
luasnip.config.setup({})
|
||||
-- Completion
|
||||
luasnip.config.setup({})
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- elseif luasnip.expand_or_jumpable() then
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{
|
||||
name = "copilot",
|
||||
priority = 8,
|
||||
keyword_length = 1,
|
||||
filter = function(keyword)
|
||||
-- Check if keyword length is some number and not just whitespace
|
||||
if #keyword < 2 or keyword:match("^%s*$") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
},
|
||||
{ name = "nvim_lsp", priority = 9 },
|
||||
{ nane = "buffer", priority = 7 },
|
||||
{ name = "luasnip", priority = 6 },
|
||||
{ name = "path" },
|
||||
{ name = "crates" },
|
||||
},
|
||||
sorting = {
|
||||
priority_weight = 1,
|
||||
comparators = {
|
||||
cmp.config.compare.locality,
|
||||
cmp.config.compare.recently_used,
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
})
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- elseif luasnip.expand_or_jumpable() then
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{
|
||||
name = "copilot",
|
||||
priority = 8,
|
||||
keyword_length = 1,
|
||||
filter = function(keyword)
|
||||
-- Check if keyword length is some number and not just whitespace
|
||||
if #keyword < 2 or keyword:match("^%s*$") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
},
|
||||
{ name = "nvim_lsp", priority = 9 },
|
||||
{ nane = "buffer", priority = 7 },
|
||||
{ name = "luasnip", priority = 6 },
|
||||
{ name = "path" },
|
||||
{ name = "crates" },
|
||||
},
|
||||
sorting = {
|
||||
priority_weight = 1,
|
||||
comparators = {
|
||||
cmp.config.compare.locality,
|
||||
cmp.config.compare.recently_used,
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
})
|
||||
|
||||
-- Window borders for visibility
|
||||
local _border = "single"
|
||||
|
||||
-- Window borders for visibility
|
||||
local _border = "single"
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = _border,
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover, {
|
||||
border = _border
|
||||
}
|
||||
)
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = _border,
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, {
|
||||
border = _border
|
||||
}
|
||||
)
|
||||
vim.diagnostic.config({
|
||||
float = { border = _border },
|
||||
})
|
||||
|
||||
vim.diagnostic.config {
|
||||
float = { border = _border }
|
||||
}
|
||||
|
||||
require('lspconfig.ui.windows').default_options = {
|
||||
border = _border
|
||||
}
|
||||
end,
|
||||
},
|
||||
{ -- Rust tools
|
||||
"simrat39/rust-tools.nvim",
|
||||
build = prereqs,
|
||||
opts = {
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp"))
|
||||
require("rust-tools").setup(opts)
|
||||
end,
|
||||
--config = function(_, opts)
|
||||
--require('rust-tools').setup(opts)
|
||||
--end
|
||||
},
|
||||
{ "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} },
|
||||
require("lspconfig.ui.windows").default_options = {
|
||||
border = _border,
|
||||
}
|
||||
end,
|
||||
},
|
||||
{ -- Rust tools
|
||||
"simrat39/rust-tools.nvim",
|
||||
build = prereqs,
|
||||
opts = {
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp"))
|
||||
require("rust-tools").setup(opts)
|
||||
end,
|
||||
--config = function(_, opts)
|
||||
--require('rust-tools').setup(opts)
|
||||
--end
|
||||
},
|
||||
{ "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} },
|
||||
}
|
||||
|
|
|
@ -1,105 +1,108 @@
|
|||
local function prereqs()
|
||||
local output = vim.fn.system({
|
||||
"which",
|
||||
"rg",
|
||||
})
|
||||
if output == nil or output == "" or string.find(output, "not installed for the toolchain") then
|
||||
print("Installing ripgrep globally with rtx")
|
||||
vim.fn.system({
|
||||
"rtx",
|
||||
"global",
|
||||
"ripgrep@latest",
|
||||
})
|
||||
end
|
||||
local output = vim.fn.system({
|
||||
"which",
|
||||
"rg",
|
||||
})
|
||||
if output == nil or output == "" or string.find(output, "not installed for the toolchain") then
|
||||
print("Installing ripgrep globally with rtx")
|
||||
vim.fn.system({
|
||||
"rtx",
|
||||
"global",
|
||||
"ripgrep@latest",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.1",
|
||||
dependencies = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable("make") == 1, build = "make" },
|
||||
},
|
||||
build = prereqs,
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ "<leader>f", "<Nop>", desc = "Find ..." },
|
||||
{
|
||||
"<leader>fr",
|
||||
function()
|
||||
require("telescope.builtin").resume()
|
||||
end,
|
||||
desc = "Resume last telescope",
|
||||
},
|
||||
{
|
||||
"<leader>ff",
|
||||
function()
|
||||
require("telescope.builtin").find_files({
|
||||
hidden = true,
|
||||
})
|
||||
end,
|
||||
desc = "Find Files",
|
||||
},
|
||||
{
|
||||
"<leader>fg",
|
||||
function()
|
||||
require("telescope.builtin").git_files()
|
||||
end,
|
||||
desc = "Find Git only Files",
|
||||
},
|
||||
{
|
||||
"<leader>fw",
|
||||
function()
|
||||
if vim.fn.executable("rg") == 0 then
|
||||
vim.notify("rg not installed, live grep will not function.", 3)
|
||||
end
|
||||
require("telescope.builtin").live_grep({
|
||||
grep_open_files = true,
|
||||
})
|
||||
end,
|
||||
desc = "Find Words",
|
||||
},
|
||||
{
|
||||
"<leader>fc",
|
||||
function()
|
||||
require("telescope.builtin").commands()
|
||||
end,
|
||||
desc = "Find Commands",
|
||||
},
|
||||
{
|
||||
"<leader>fk",
|
||||
function()
|
||||
require("telescope.builtin").keymaps()
|
||||
end,
|
||||
desc = "Find Commands",
|
||||
},
|
||||
{
|
||||
"<leader>fb",
|
||||
function()
|
||||
require("telescope.builtin").buffers()
|
||||
end,
|
||||
desc = "Find Commands",
|
||||
},
|
||||
{
|
||||
"<leader>lfr",
|
||||
function()
|
||||
require("telescope.builtin").lsp_references()
|
||||
end,
|
||||
desc = "Find References", mode ={"n", "v", "x"}
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
pickers = {
|
||||
buffers = {
|
||||
sort_lastused = true,
|
||||
},
|
||||
find_files = {
|
||||
hidden = true,
|
||||
sort_lastused = true,
|
||||
},
|
||||
},
|
||||
defaults = {
|
||||
file_ignore_patterns = { "node_modules", "package-lock.json", "target" },
|
||||
},
|
||||
},
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.1",
|
||||
dependencies = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable("make") == 1, build = "make" },
|
||||
},
|
||||
build = prereqs,
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ "<leader>f", "<Nop>", desc = "Find ..." },
|
||||
{
|
||||
"<leader>fr",
|
||||
function()
|
||||
require("telescope.builtin").resume()
|
||||
end,
|
||||
desc = "Resume last telescope",
|
||||
},
|
||||
{
|
||||
"<leader>ff",
|
||||
function()
|
||||
require("telescope.builtin").find_files({
|
||||
hidden = true,
|
||||
})
|
||||
end,
|
||||
desc = "Find Files",
|
||||
},
|
||||
{
|
||||
"<leader>fg",
|
||||
function()
|
||||
require("telescope.builtin").git_files({
|
||||
hidden = true,
|
||||
})
|
||||
end,
|
||||
desc = "Find Git only Files",
|
||||
},
|
||||
{
|
||||
"<leader>fw",
|
||||
function()
|
||||
if vim.fn.executable("rg") == 0 then
|
||||
vim.notify("rg not installed, live grep will not function.", 3)
|
||||
end
|
||||
require("telescope.builtin").live_grep({
|
||||
hidden = true,
|
||||
})
|
||||
end,
|
||||
desc = "Find Words",
|
||||
},
|
||||
{
|
||||
"<leader>fc",
|
||||
function()
|
||||
require("telescope.builtin").commands()
|
||||
end,
|
||||
desc = "Find Commands",
|
||||
},
|
||||
{
|
||||
"<leader>fk",
|
||||
function()
|
||||
require("telescope.builtin").keymaps()
|
||||
end,
|
||||
desc = "Find Commands",
|
||||
},
|
||||
{
|
||||
"<leader>fb",
|
||||
function()
|
||||
require("telescope.builtin").buffers()
|
||||
end,
|
||||
desc = "Find Commands",
|
||||
},
|
||||
{
|
||||
"<leader>lfr",
|
||||
function()
|
||||
require("telescope.builtin").lsp_references()
|
||||
end,
|
||||
desc = "Find References",
|
||||
mode = { "n", "v", "x" },
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
pickers = {
|
||||
buffers = {
|
||||
sort_lastused = true,
|
||||
},
|
||||
find_files = {
|
||||
hidden = true,
|
||||
sort_lastused = true,
|
||||
},
|
||||
},
|
||||
defaults = {
|
||||
file_ignore_patterns = { "node_modules", "package-lock.json", "target" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue