add dap and copilot
This commit is contained in:
94
lua/dkelly/plugins/dap.lua
Normal file
94
lua/dkelly/plugins/dap.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
return {
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
"leoluz/nvim-dap-go",
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
"nvim-neotest/nvim-nio",
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
local ui = require("dapui")
|
||||
|
||||
require("dapui").setup()
|
||||
require("dap-go").setup()
|
||||
|
||||
require("nvim-dap-virtual-text").setup({
|
||||
-- This just tries to mitigate the chance that I leak tokens here. Probably won't stop it from happening...
|
||||
display_callback = function(variable)
|
||||
local name = string.lower(variable.name)
|
||||
local value = string.lower(variable.value)
|
||||
if name:match("secret") or name:match("api") or value:match("secret") or value:match("api") then
|
||||
return "*****"
|
||||
end
|
||||
|
||||
if #variable.value > 15 then
|
||||
return " " .. string.sub(variable.value, 1, 15) .. "... "
|
||||
end
|
||||
|
||||
return " " .. variable.value
|
||||
end,
|
||||
})
|
||||
|
||||
-- Handled by nvim-dap-go
|
||||
-- dap.adapters.go = {
|
||||
-- type = "server",
|
||||
-- port = "${port}",
|
||||
-- executable = {
|
||||
-- command = "dlv",
|
||||
-- args = { "dap", "-l", "127.0.0.1:${port}" },
|
||||
-- },
|
||||
-- }
|
||||
|
||||
local elixir_ls_debugger = vim.fn.exepath("elixir-ls-debugger")
|
||||
if elixir_ls_debugger ~= "" then
|
||||
dap.adapters.mix_task = {
|
||||
type = "executable",
|
||||
command = elixir_ls_debugger,
|
||||
}
|
||||
|
||||
dap.configurations.elixir = {
|
||||
{
|
||||
type = "mix_task",
|
||||
name = "phoenix server",
|
||||
task = "phx.server",
|
||||
request = "launch",
|
||||
projectDir = "${workspaceFolder}",
|
||||
exitAfterTaskReturns = false,
|
||||
debugAutoInterpretAllModules = false,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>bb", dap.toggle_breakpoint)
|
||||
-- vim.keymap.set("n", "<leader>gb", dap.run_to_cursor)
|
||||
|
||||
-- Eval var under cursor
|
||||
vim.keymap.set("n", "<leader>be", function()
|
||||
require("dapui").eval(nil, { enter = true })
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<F1>", dap.continue)
|
||||
vim.keymap.set("n", "<F2>", dap.step_into)
|
||||
vim.keymap.set("n", "<F3>", dap.step_over)
|
||||
vim.keymap.set("n", "<F4>", dap.step_out)
|
||||
vim.keymap.set("n", "<F5>", dap.step_back)
|
||||
vim.keymap.set("n", "<F13>", dap.restart)
|
||||
|
||||
dap.listeners.before.attach.dapui_config = function()
|
||||
ui.open()
|
||||
end
|
||||
dap.listeners.before.launch.dapui_config = function()
|
||||
ui.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated.dapui_config = function()
|
||||
ui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited.dapui_config = function()
|
||||
ui.close()
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
40
lua/dkelly/plugins/gh-copilot.lua
Normal file
40
lua/dkelly/plugins/gh-copilot.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
return {
|
||||
{
|
||||
"CopilotC-Nvim/CopilotChat.nvim",
|
||||
dependencies = {
|
||||
-- Use whichever Copilot plugin you prefer, but configure it as above
|
||||
{ "zbirenbaum/copilot.lua" },
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
},
|
||||
build = "make tiktoken",
|
||||
opts = {},
|
||||
keys = {
|
||||
{ "<leader>cc", "<cmd>CopilotChatToggle<cr>", desc = "Open Copilot Chat" },
|
||||
},
|
||||
cmd = { "CopilotChat" },
|
||||
},
|
||||
{
|
||||
"zbirenbaum/copilot.lua",
|
||||
config = function()
|
||||
require("copilot").setup({
|
||||
suggestion = {
|
||||
enabled = true,
|
||||
auto_trigger = true,
|
||||
keymap = {
|
||||
accept = "<C-a>",
|
||||
},
|
||||
},
|
||||
panel = { enabled = false },
|
||||
})
|
||||
vim.keymap.set("n", "<leader>cs", function()
|
||||
-- flips the auto_trigger for the current buffer
|
||||
require("copilot.suggestion").toggle_auto_trigger()
|
||||
-- read the buffer-local flag that Copilot sets under the hood
|
||||
local on = vim.b.copilot_suggestion_auto_trigger or false
|
||||
print("Copilot suggestions " .. (on and "enabled" or "disabled"))
|
||||
end, { desc = "Toggle Copilot inline suggestions" })
|
||||
end,
|
||||
-- Don't lazy-load, CopilotChat needs backend running
|
||||
event = "VeryLazy",
|
||||
},
|
||||
}
|
||||
@@ -1,107 +1,157 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
},
|
||||
config = function()
|
||||
-- import lspconfig plugin
|
||||
local lspconfig = require("lspconfig")
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
},
|
||||
config = function()
|
||||
-- import lspconfig plugin
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- import mason_lspconfig plugin
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
-- import mason_lspconfig plugin
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
-- import cmp-nvim-lsp plugin
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
-- import cmp-nvim-lsp plugin
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
|
||||
-- set keybinds
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
|
||||
-- set keybinds
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
|
||||
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
|
||||
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
|
||||
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
|
||||
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
|
||||
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>cz", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
|
||||
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
|
||||
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
|
||||
|
||||
opts.desc = "Show line diagnostics"
|
||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
|
||||
opts.desc = "Show line diagnostics"
|
||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
|
||||
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
|
||||
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
|
||||
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
|
||||
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
|
||||
end,
|
||||
})
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
|
||||
end,
|
||||
})
|
||||
|
||||
-- used to enable autocompletion (assign to every lsp server config)
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
-- used to enable autocompletion (assign to every lsp server config)
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
-- Change the Diagnostic symbols in the sign column (gutter)
|
||||
-- (not in youtube nvim video)
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <C-x><C-o>
|
||||
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
|
||||
mason_lspconfig.setup_handlers({
|
||||
-- default handler for installed servers
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
["lua_ls"] = function()
|
||||
-- configure lua server (with special settings)
|
||||
lspconfig["lua_ls"].setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
-- make the language server recognize "vim" global
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
-- Define key mappings for LSP functionality
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
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", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<leader>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts)
|
||||
|
||||
-- Additional client-specific setup
|
||||
if client.server_capabilities.document_highlight then
|
||||
vim.api.nvim_create_augroup("LspDocumentHighlight", { clear = true })
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = "LspDocumentHighlight",
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
group = "LspDocumentHighlight",
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
end
|
||||
end
|
||||
-- Change the Diagnostic symbols in the sign column (gutter)
|
||||
-- (not in youtube nvim video)
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
|
||||
mason_lspconfig.setup_handlers({
|
||||
-- default handler for installed servers
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
["lua_ls"] = function()
|
||||
-- configure lua server (with special settings)
|
||||
lspconfig["lua_ls"].setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
-- make the language server recognize "vim" global
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
["gopls"] = function()
|
||||
lspconfig.gopls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_dir = lspconfig.util.root_pattern("go.work", "go.mod", ".git"),
|
||||
settings = {
|
||||
gopls = {
|
||||
completeUnimported = true,
|
||||
usePlaceholder = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -31,12 +31,10 @@ return {
|
||||
"cssls", -- CSS
|
||||
"gopls", -- Go
|
||||
"html", -- HTML
|
||||
"tsserver", -- TypeScript/JavaScript
|
||||
"jsonls", -- JSON
|
||||
"lua_ls", -- Lua
|
||||
"marksman", -- Markdown
|
||||
"pyright", -- Python
|
||||
"ruby_ls", -- Ruby
|
||||
"rust_analyzer", -- Rust
|
||||
"taplo", -- TOML
|
||||
"yamlls", -- YAML
|
||||
|
||||
Reference in New Issue
Block a user