This commit is contained in:
RingOfStorms (Joshua Bell) 2023-08-13 21:18:51 -05:00
parent f607bde009
commit d7d4d85972
5 changed files with 270 additions and 268 deletions

View file

@ -13,32 +13,37 @@
--}) --})
vim.api.nvim_create_autocmd("BufRead", { vim.api.nvim_create_autocmd("BufRead", {
pattern = ".env*", pattern = ".env*",
command = "set filetype=sh", command = "set filetype=sh",
}) })
vim.api.nvim_create_autocmd("BufRead", { vim.api.nvim_create_autocmd("BufRead", {
pattern = ".*rc", pattern = ".*rc",
command = "set filetype=sh", command = "set filetype=sh",
}) })
vim.api.nvim_create_autocmd("BufRead", { vim.api.nvim_create_autocmd("BufRead", {
pattern = "Dockerfile.*", pattern = "Dockerfile.*",
command = "set filetype=dockerfile", command = "set filetype=dockerfile",
}) })
vim.api.nvim_create_autocmd("BufRead", { vim.api.nvim_create_autocmd("BufRead", {
callback = function() callback = function()
vim.cmd.CccHighlighterEnable() vim.cmd.CccHighlighterEnable()
end, end,
}) })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
callback = function() callback = function()
-- if vim.bo.filetype == 'neo-tree' then -- if vim.bo.filetype == 'neo-tree' then
vim.api.nvim_command("stopinsert") vim.api.nvim_command("stopinsert")
-- end -- end
end end,
})
vim.api.nvim_create_autocmd({ "BufEnter" }, {
pattern = "*.http",
command = "set filetype=http",
}) })
--vim.api.nvim_create_autocmd('BufEnter', { --vim.api.nvim_create_autocmd('BufEnter', {

View file

@ -21,8 +21,8 @@ require("util").keymaps({
["<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>q"] = { "<cmd>confirm q<cr>", desc = "Quit" }, ["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" },
["<leader>cq"] = { "<cmd>bd<cr>", desc = "Close current buffer" }, ["<leader>bq"] = { "<cmd>bp|bd #<cr>", desc = "Close current buffer only" },
["<leader>tn"] = { "<cmd>tabnew<cr>", desc = "" }, ["<leader>tn"] = { "<cmd>tabnew<cr>", desc = "Create new tab" },
["<leader>tq"] = { "<cmd>tabclose<cr>", desc = "Close current tab" }, ["<leader>tq"] = { "<cmd>tabclose<cr>", desc = "Close current tab" },
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" }, ["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" }, ["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
@ -63,7 +63,7 @@ require("util").keymaps({
}, },
["<leader>lz"] = { "<cmd>e<CR>", desc = "Edit current file again / Restart LSP Server" }, ["<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" }, ["<leader>,uu"] = { ':let @u = trim(tolower(system("uuidgen")))<cr>a<C-r>u', desc = "Generate and insert UUID" },
["<leader>b"] = { "<cmd>b#<cr>", desc = "Switch to last buffer" }, ["B"] = { "<cmd>b#<cr>", desc = "Switch to last buffer" },
}, },
v = { v = {
["J"] = { ":m '>+1<CR>gv=gv", desc = "Visually move block down" }, ["J"] = { ":m '>+1<CR>gv=gv", desc = "Visually move block down" },

View file

@ -2,6 +2,9 @@ return {
"rest-nvim/rest.nvim", "rest-nvim/rest.nvim",
event = "BufEnter *.http", event = "BufEnter *.http",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
opts = {
encode_url = false,
},
keys = { keys = {
{ {
"<leader>r", "<leader>r",

View file

@ -1,284 +1,278 @@
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,
}) })
local signs = { "Error", "Warn", "Hint", "Info" }
for _, type in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = "", texthl = hl, numhl = hl })
end
-- LSP config -- LSP config
-- Took lots of inspiration from this kickstart lua file: https://github.com/hjr3/dotfiles/blob/main/.config/nvim/init.lua -- Took lots of inspiration from this kickstart lua file: https://github.com/hjr3/dotfiles/blob/main/.config/nvim/init.lua
-- 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") nmap("<leader>lr", vim.lsp.buf.rename, "[R]ename")
nmap("<leader>la", vim.lsp.buf.code_action, "Code [A]ction") nmap("<leader>la", vim.lsp.buf.code_action, "Code [A]ction")
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation") nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition") nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
-- See `:help K` for why this keymap -- See `:help K` for why this keymap
nmap("K", vim.lsp.buf.hover, "Hover Documentation") nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation") nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality -- Lesser used LSP functionality
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
-- disable tsserver so it does not conflict with prettier -- disable tsserver so it does not conflict with prettier
if client.name == "tsserver" then if client.name == "tsserver" then
client.server_capabilities.document_formatting = false client.server_capabilities.document_formatting = false
end 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",
}, },
{ {
-- 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
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", priority = 9 }, { name = "copilot", priority = 8 },
{ name = "nvim_lsp", priority = 8 }, { 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(),
}, },
}) })
end, end,
}, },
{ -- Rust tools { -- Rust tools
"simrat39/rust-tools.nvim", "simrat39/rust-tools.nvim",
build = prereqs, build = prereqs,
opts = { opts = {
server = { server = {
on_attach = on_attach, on_attach = on_attach,
}, },
}, },
config = function(_, opts) config = function(_, opts)
opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp")) opts.server.capabilities = gen_capabilities(require("cmp_nvim_lsp"))
require("rust-tools").setup(opts) require("rust-tools").setup(opts)
end, end,
--config = function(_, opts) --config = function(_, opts)
--require('rust-tools').setup(opts) --require('rust-tools').setup(opts)
--end --end
}, },
{ "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} }, { "Saecki/crates.nvim", tag = "v0.3.0", dependencies = { "nvim-lua/plenary.nvim" }, opts = {} },
} }