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