feat: add plugin
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
parent
3338d39206
commit
bde55c5fed
291
init.lua
291
init.lua
|
|
@ -93,6 +93,90 @@ vim.g.maplocalleader = ' '
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = false
|
||||||
|
|
||||||
|
-- [[ LSP ]]
|
||||||
|
vim.g.rustaceanvim = function()
|
||||||
|
-- Update this path
|
||||||
|
local mason_registry = require 'mason-registry'
|
||||||
|
|
||||||
|
local codelldb = vim.fn.expand '$MASON/packages/codelldb'
|
||||||
|
local extension_path = codelldb .. '/extension/'
|
||||||
|
local codelldb_path = extension_path .. 'adapter/codelldb'
|
||||||
|
local liblldb_path = extension_path .. 'lldb/lib/liblldb'
|
||||||
|
local this_os = vim.uv.os_uname().sysname
|
||||||
|
|
||||||
|
-- The path is different on Windows
|
||||||
|
if this_os:find 'Windows' then
|
||||||
|
codelldb_path = extension_path .. 'adapter\\codelldb.exe'
|
||||||
|
liblldb_path = extension_path .. 'lldb\\bin\\liblldb.dll'
|
||||||
|
else
|
||||||
|
-- The liblldb extension is .so for Linux and .dylib for MacOS
|
||||||
|
liblldb_path = liblldb_path .. (this_os == 'Linux' and '.so' or '.dylib')
|
||||||
|
end
|
||||||
|
|
||||||
|
local cfg = require 'rustaceanvim.config'
|
||||||
|
return {
|
||||||
|
--- Plugin configuration
|
||||||
|
tools = {},
|
||||||
|
--- LSP Configuration
|
||||||
|
server = {
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
-- you can also put keymaps in here
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', { noremap = true, silent = true })
|
||||||
|
end,
|
||||||
|
default_settings = {
|
||||||
|
-- rust-analyzer language server configuration
|
||||||
|
['rust-analyzer'] = {
|
||||||
|
procMacro = { enable = true },
|
||||||
|
cachePriming = {
|
||||||
|
enable = true,
|
||||||
|
numThreads = 12,
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
enableExperimental = false,
|
||||||
|
},
|
||||||
|
check = {
|
||||||
|
command = 'clippy',
|
||||||
|
allTargets = false,
|
||||||
|
allFeatures = false,
|
||||||
|
},
|
||||||
|
cargo = {
|
||||||
|
allFeatures = false,
|
||||||
|
loadOutDirsFromCheck = true,
|
||||||
|
runBuildScripts = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- DAP configuration
|
||||||
|
dap = {
|
||||||
|
adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.config('pyrefly', {
|
||||||
|
cmd = { 'pyrefly', 'lsp' },
|
||||||
|
filetypes = { 'python' },
|
||||||
|
root_dir = vim.fs.root(0, { 'pyproject.toml', 'setup.cfg', 'setup.py', '.git' }),
|
||||||
|
single_file_support = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.enable 'pyrefly'
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('User', {
|
||||||
|
pattern = 'GitConflictDetected',
|
||||||
|
callback = function()
|
||||||
|
vim.notify('Conflict detected in ' .. vim.fn.expand '<afile>')
|
||||||
|
vim.keymap.set('n', 'cww', function()
|
||||||
|
engage.conflict_buster()
|
||||||
|
create_buffer_local_mappings()
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.o`
|
-- See `:help vim.o`
|
||||||
-- NOTE: You can change these options as you wish!
|
-- NOTE: You can change these options as you wish!
|
||||||
|
|
@ -102,7 +186,7 @@ vim.g.have_nerd_font = false
|
||||||
vim.o.number = true
|
vim.o.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- Experiment for yourself to see if you like it!
|
||||||
-- vim.o.relativenumber = true
|
vim.o.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.o.mouse = 'a'
|
vim.o.mouse = 'a'
|
||||||
|
|
@ -110,6 +194,18 @@ vim.o.mouse = 'a'
|
||||||
-- Don't show the mode, since it's already in the status line
|
-- Don't show the mode, since it's already in the status line
|
||||||
vim.o.showmode = false
|
vim.o.showmode = false
|
||||||
|
|
||||||
|
-- A <Tab> in file is 2 spaces
|
||||||
|
vim.opt.tabstop = 2
|
||||||
|
|
||||||
|
-- Indentation amount
|
||||||
|
vim.opt.shiftwidth = 2
|
||||||
|
|
||||||
|
-- Editing behavior (backspace/del)
|
||||||
|
vim.opt.softtabstop = 2
|
||||||
|
|
||||||
|
-- Use spaces, not tabs
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
|
||||||
-- Sync clipboard between OS and Neovim.
|
-- Sync clipboard between OS and Neovim.
|
||||||
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||||
-- Remove this option if you want your OS clipboard to remain independent.
|
-- Remove this option if you want your OS clipboard to remain independent.
|
||||||
|
|
@ -174,6 +270,7 @@ vim.o.confirm = true
|
||||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
-- Diagnostic keymaps
|
||||||
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror message' })
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||||
|
|
||||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
||||||
|
|
@ -437,6 +534,14 @@ require('lazy').setup({
|
||||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||||
|
|
||||||
|
-- Git Worktree
|
||||||
|
vim.keymap.set('n', '<leader>gw', "<CMD>lua require('telescope').extensions.git_worktree()CR", {
|
||||||
|
desc = 'Git Worktrees',
|
||||||
|
})
|
||||||
|
vim.keymap.set('n', '<leader>gW', "<CMD>lua require('telescope').extensions.create_git_worktree()CR", {
|
||||||
|
desc = 'Create Git Worktree',
|
||||||
|
})
|
||||||
|
|
||||||
-- Slightly advanced example of overriding default behavior and theme
|
-- Slightly advanced example of overriding default behavior and theme
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
vim.keymap.set('n', '<leader>/', function()
|
||||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||||
|
|
@ -660,7 +765,7 @@ require('lazy').setup({
|
||||||
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
|
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
|
||||||
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
|
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
|
||||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||||
|
capabilities.offsetEncoding = { 'utf-8' }
|
||||||
-- Enable the following language servers
|
-- Enable the following language servers
|
||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
--
|
--
|
||||||
|
|
@ -673,7 +778,13 @@ require('lazy').setup({
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
-- clangd = {},
|
||||||
-- gopls = {},
|
-- gopls = {},
|
||||||
-- pyright = {},
|
-- pyright = {
|
||||||
|
-- settings = {
|
||||||
|
-- python = {
|
||||||
|
-- pythonPath = './.venv/bin/python',
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
||||||
--
|
--
|
||||||
|
|
@ -682,7 +793,51 @@ require('lazy').setup({
|
||||||
--
|
--
|
||||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
||||||
-- ts_ls = {},
|
-- ts_ls = {},
|
||||||
--
|
tailwindcss = {
|
||||||
|
filetypes = { 'html', 'css', 'javascriptreact', 'typescriptreact', 'vue', 'svelte' },
|
||||||
|
-- If you need to add custom filetypes or logic:
|
||||||
|
-- settings = {
|
||||||
|
-- tailwindCSS = {
|
||||||
|
-- includeLanguages = {
|
||||||
|
-- elixir = "html-eex",
|
||||||
|
-- heex = "html-eex",
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
},
|
||||||
|
pylsp = {
|
||||||
|
settings = {
|
||||||
|
pylsp = {
|
||||||
|
plugins = {
|
||||||
|
pyflakes = { enabled = false },
|
||||||
|
pycodestyle = { enabled = false },
|
||||||
|
autopep8 = { enabled = false },
|
||||||
|
yapf = { enabled = false },
|
||||||
|
mccabe = { enabled = false },
|
||||||
|
pylsp_mypy = { enabled = false },
|
||||||
|
pylsp_black = { enabled = false },
|
||||||
|
pylsp_isort = { enabled = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ruff = {
|
||||||
|
-- Notes on code actions: https://github.com/astral-sh/ruff-lsp/issues/119#issuecomment-1595628355
|
||||||
|
-- Get isort like behavior: https://github.com/astral-sh/ruff/issues/8926#issuecomment-1834048218
|
||||||
|
commands = {
|
||||||
|
RuffAutofix = {
|
||||||
|
function()
|
||||||
|
vim.lsp.buf.execute_command {
|
||||||
|
command = 'ruff.applyAutofix',
|
||||||
|
arguments = {
|
||||||
|
{ uri = vim.uri_from_bufnr(0) },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
description = 'Ruff: Fix all auto-fixable problems',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
-- cmd = { ... },
|
-- cmd = { ... },
|
||||||
|
|
@ -719,63 +874,59 @@ require('lazy').setup({
|
||||||
})
|
})
|
||||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||||
|
|
||||||
require('mason-lspconfig').setup {
|
for server, cfg in pairs(servers) do
|
||||||
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
|
-- For each LSP server (cfg), we merge:
|
||||||
automatic_installation = false,
|
-- 1. A fresh empty table (to avoid mutating capabilities globally)
|
||||||
handlers = {
|
-- 2. Your capabilities object with Neovim + cmp features
|
||||||
function(server_name)
|
-- 3. Any server-specific cfg.capabilities if defined in `servers`
|
||||||
local server = servers[server_name] or {}
|
cfg.capabilities = vim.tbl_deep_extend('force', {}, capabilities, cfg.capabilities or {})
|
||||||
-- This handles overriding only values explicitly passed
|
|
||||||
-- by the server configuration above. Useful when disabling
|
vim.lsp.config(server, cfg)
|
||||||
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
vim.lsp.enable(server)
|
||||||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
end
|
||||||
require('lspconfig')[server_name].setup(server)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Autoformat
|
-- { -- Autoformat
|
||||||
'stevearc/conform.nvim',
|
-- 'stevearc/conform.nvim',
|
||||||
event = { 'BufWritePre' },
|
-- event = { 'BufWritePre' },
|
||||||
cmd = { 'ConformInfo' },
|
-- cmd = { 'ConformInfo' },
|
||||||
keys = {
|
-- keys = {
|
||||||
{
|
-- {
|
||||||
'<leader>f',
|
-- '<leader>f',
|
||||||
function()
|
-- function()
|
||||||
require('conform').format { async = true, lsp_format = 'fallback' }
|
-- require('conform').format { async = true, lsp_format = 'fallback' }
|
||||||
end,
|
-- end,
|
||||||
mode = '',
|
-- mode = '',
|
||||||
desc = '[F]ormat buffer',
|
-- desc = '[F]ormat buffer',
|
||||||
},
|
-- },
|
||||||
},
|
-- },
|
||||||
opts = {
|
-- opts = {
|
||||||
notify_on_error = false,
|
-- notify_on_error = false,
|
||||||
format_on_save = function(bufnr)
|
-- format_on_save = function(bufnr)
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
-- -- Disable "format_on_save lsp_fallback" for languages that don't
|
||||||
-- have a well standardized coding style. You can add additional
|
-- -- have a well standardized coding style. You can add additional
|
||||||
-- languages here or re-enable it for the disabled ones.
|
-- -- languages here or re-enable it for the disabled ones.
|
||||||
local disable_filetypes = { c = true, cpp = true }
|
-- local disable_filetypes = { c = true, cpp = true }
|
||||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
-- if disable_filetypes[vim.bo[bufnr].filetype] then
|
||||||
return nil
|
-- return nil
|
||||||
else
|
-- else
|
||||||
return {
|
-- return {
|
||||||
timeout_ms = 500,
|
-- timeout_ms = 500,
|
||||||
lsp_format = 'fallback',
|
-- lsp_format = 'fallback',
|
||||||
}
|
-- }
|
||||||
end
|
-- end
|
||||||
end,
|
-- end,
|
||||||
formatters_by_ft = {
|
-- formatters_by_ft = {
|
||||||
lua = { 'stylua' },
|
-- lua = { 'stylua' },
|
||||||
-- Conform can also run multiple formatters sequentially
|
-- -- Conform can also run multiple formatters sequentially
|
||||||
-- python = { "isort", "black" },
|
-- -- python = { "isort", "black" },
|
||||||
--
|
-- --
|
||||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
-- -- You can use 'stop_after_first' to run the first available formatter from the list
|
||||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
-- -- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||||
},
|
-- },
|
||||||
},
|
-- },
|
||||||
},
|
-- },
|
||||||
|
|
||||||
{ -- Autocompletion
|
{ -- Autocompletion
|
||||||
'saghen/blink.cmp',
|
'saghen/blink.cmp',
|
||||||
|
|
@ -799,12 +950,12 @@ require('lazy').setup({
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
-- See the README about individual language/framework/plugin snippets:
|
-- See the README about individual language/framework/plugin snippets:
|
||||||
-- https://github.com/rafamadriz/friendly-snippets
|
-- https://github.com/rafamadriz/friendly-snippets
|
||||||
-- {
|
{
|
||||||
-- 'rafamadriz/friendly-snippets',
|
'rafamadriz/friendly-snippets',
|
||||||
-- config = function()
|
config = function()
|
||||||
-- require('luasnip.loaders.from_vscode').lazy_load()
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
-- end,
|
end,
|
||||||
-- },
|
},
|
||||||
},
|
},
|
||||||
opts = {},
|
opts = {},
|
||||||
},
|
},
|
||||||
|
|
@ -944,7 +1095,7 @@ require('lazy').setup({
|
||||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
opts = {
|
opts = {
|
||||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
|
ensure_installed = { 'python', 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
|
||||||
-- Autoinstall languages that are not installed
|
-- Autoinstall languages that are not installed
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {
|
highlight = {
|
||||||
|
|
@ -973,18 +1124,18 @@ require('lazy').setup({
|
||||||
-- Here are some example plugins that I've included in the Kickstart repository.
|
-- Here are some example plugins that I've included in the Kickstart repository.
|
||||||
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
|
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
|
||||||
--
|
--
|
||||||
-- require 'kickstart.plugins.debug',
|
require 'kickstart.plugins.debug',
|
||||||
-- require 'kickstart.plugins.indent_line',
|
-- require 'kickstart.plugins.indent_line',
|
||||||
-- require 'kickstart.plugins.lint',
|
require 'kickstart.plugins.lint',
|
||||||
-- require 'kickstart.plugins.autopairs',
|
-- require 'kickstart.plugins.autopairs',
|
||||||
-- require 'kickstart.plugins.neo-tree',
|
require 'kickstart.plugins.neo-tree',
|
||||||
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
||||||
|
|
||||||
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||||
-- This is the easiest way to modularize your config.
|
-- This is the easiest way to modularize your config.
|
||||||
--
|
--
|
||||||
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
||||||
-- { import = 'custom.plugins' },
|
{ import = 'custom.plugins' },
|
||||||
--
|
--
|
||||||
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
|
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
|
||||||
-- Or use telescope!
|
-- Or use telescope!
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- You can add your own plugins here or in other files in this directory!
|
||||||
|
-- I promise not to create any merge conflicts in this directory :)
|
||||||
|
--
|
||||||
|
-- See the kickstart.nvim README for more information
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'akinsho/git-conflict.nvim',
|
||||||
|
version = '*',
|
||||||
|
config = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'ThePrimeagen/git-worktree.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('git-worktree').setup()
|
||||||
|
require('telescope').load_extension 'git_worktree'
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
-- Format on save and linters
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'nvimtools/none-ls.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvimtools/none-ls-extras.nvim',
|
||||||
|
'jayp0521/mason-null-ls.nvim', -- ensure dependencies are installed
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local null_ls = require 'null-ls'
|
||||||
|
local formatting = null_ls.builtins.formatting -- to setup formatters
|
||||||
|
local diagnostics = null_ls.builtins.diagnostics -- to setup linters
|
||||||
|
|
||||||
|
-- list of formatters & linters for mason to install
|
||||||
|
require('mason-null-ls').setup {
|
||||||
|
ensure_installed = {
|
||||||
|
'checkmake',
|
||||||
|
'prettier', -- ts/js formatter
|
||||||
|
'stylua', -- lua formatter
|
||||||
|
'eslint_d', -- ts/js linter
|
||||||
|
'shfmt',
|
||||||
|
'ruff',
|
||||||
|
},
|
||||||
|
-- auto-install configured formatters & linters (with null-ls)
|
||||||
|
automatic_installation = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local sources = {
|
||||||
|
-- Linters
|
||||||
|
diagnostics.checkmake,
|
||||||
|
|
||||||
|
-- ESLint diagnostics (ESLint 9 compatible)
|
||||||
|
require('none-ls.diagnostics.eslint_d').with {
|
||||||
|
prefer_local = 'node_modules/.bin',
|
||||||
|
filetypes = {
|
||||||
|
'javascript',
|
||||||
|
'typescript',
|
||||||
|
'javascriptreact',
|
||||||
|
'typescriptreact',
|
||||||
|
},
|
||||||
|
condition = function(utils)
|
||||||
|
return utils.root_has_file {
|
||||||
|
'eslint.config.js',
|
||||||
|
'eslint.config.mjs',
|
||||||
|
'eslint.config.cjs',
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- ESLint code actions
|
||||||
|
require('none-ls.code_actions.eslint_d').with {
|
||||||
|
prefer_local = 'node_modules/.bin',
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Formatters
|
||||||
|
formatting.prettier.with {
|
||||||
|
filetypes = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'html', 'json', 'yaml', 'markdown' },
|
||||||
|
},
|
||||||
|
|
||||||
|
formatting.stylua,
|
||||||
|
formatting.shfmt.with { args = { '-i', '4' } },
|
||||||
|
formatting.terraform_fmt,
|
||||||
|
require('none-ls.formatting.ruff').with { extra_args = { '--config=pyproject.toml' } },
|
||||||
|
-- require('none-ls.formatting.ruff_format').with { extra_args = { '--config=pyproject.toml' } },
|
||||||
|
}
|
||||||
|
|
||||||
|
local augroup = vim.api.nvim_create_augroup('LspFormatting', {})
|
||||||
|
null_ls.setup {
|
||||||
|
-- debug = true, -- Enable debug mode. Inspect logs with :NullLsLog.
|
||||||
|
sources = sources,
|
||||||
|
-- you can reuse a shared lspconfig on_attach callback here
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
if client.supports_method 'textDocument/formatting' then
|
||||||
|
vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr }
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format { async = false }
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'mrcjkb/rustaceanvim',
|
||||||
|
version = '^6', -- Recommended
|
||||||
|
lazy = false, -- This plugin is already lazy
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'christoomey/vim-tmux-navigator',
|
||||||
|
cmd = {
|
||||||
|
'TmuxNavigateLeft',
|
||||||
|
'TmuxNavigateDown',
|
||||||
|
'TmuxNavigateUp',
|
||||||
|
'TmuxNavigateRight',
|
||||||
|
'TmuxNavigatePrevious',
|
||||||
|
'TmuxNavigatorProcessList',
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' },
|
||||||
|
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
|
||||||
|
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
|
||||||
|
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
|
||||||
|
{ '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'pmizio/typescript-tools.nvim',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -7,142 +7,178 @@
|
||||||
-- kickstart.nvim and not kitchen-sink.nvim ;)
|
-- kickstart.nvim and not kitchen-sink.nvim ;)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- NOTE: Yes, you can install new plugins here!
|
|
||||||
'mfussenegger/nvim-dap',
|
'mfussenegger/nvim-dap',
|
||||||
-- NOTE: And you can specify dependencies as well
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Creates a beautiful debugger UI
|
-- Create a beutifull debugger UI
|
||||||
'rcarriga/nvim-dap-ui',
|
'rcarriga/nvim-dap-ui',
|
||||||
|
-- Required dependency for nvim dap ui
|
||||||
-- Required dependency for nvim-dap-ui
|
'theHamsta/nvim-dap-virtual-text',
|
||||||
'nvim-neotest/nvim-nio',
|
'nvim-neotest/nvim-nio',
|
||||||
|
-- Install the debug adapter for you
|
||||||
-- Installs the debug adapters for you
|
'williamboman/mason.nvim',
|
||||||
'mason-org/mason.nvim',
|
|
||||||
'jay-babu/mason-nvim-dap.nvim',
|
'jay-babu/mason-nvim-dap.nvim',
|
||||||
|
-- Add your own debugger here
|
||||||
-- Add your own debuggers here
|
'mfussenegger/nvim-dap-python',
|
||||||
'leoluz/nvim-dap-go',
|
'leoluz/nvim-dap-go',
|
||||||
},
|
},
|
||||||
keys = {
|
|
||||||
-- Basic debugging keymaps, feel free to change to your liking!
|
|
||||||
{
|
|
||||||
'<F5>',
|
|
||||||
function()
|
|
||||||
require('dap').continue()
|
|
||||||
end,
|
|
||||||
desc = 'Debug: Start/Continue',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'<F1>',
|
|
||||||
function()
|
|
||||||
require('dap').step_into()
|
|
||||||
end,
|
|
||||||
desc = 'Debug: Step Into',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'<F2>',
|
|
||||||
function()
|
|
||||||
require('dap').step_over()
|
|
||||||
end,
|
|
||||||
desc = 'Debug: Step Over',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'<F3>',
|
|
||||||
function()
|
|
||||||
require('dap').step_out()
|
|
||||||
end,
|
|
||||||
desc = 'Debug: Step Out',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'<leader>b',
|
|
||||||
function()
|
|
||||||
require('dap').toggle_breakpoint()
|
|
||||||
end,
|
|
||||||
desc = 'Debug: Toggle Breakpoint',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'<leader>B',
|
|
||||||
function()
|
|
||||||
require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ')
|
|
||||||
end,
|
|
||||||
desc = 'Debug: Set Breakpoint',
|
|
||||||
},
|
|
||||||
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
|
|
||||||
{
|
|
||||||
'<F7>',
|
|
||||||
function()
|
|
||||||
require('dapui').toggle()
|
|
||||||
end,
|
|
||||||
desc = 'Debug: See last session result.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function()
|
config = function()
|
||||||
local dap = require 'dap'
|
local dap = require 'dap'
|
||||||
local dapui = require 'dapui'
|
local ui = require 'dapui'
|
||||||
|
|
||||||
|
require('dapui').setup()
|
||||||
|
require('dap-go').setup()
|
||||||
|
|
||||||
require('mason-nvim-dap').setup {
|
require('mason-nvim-dap').setup {
|
||||||
-- Makes a best effort to setup the various debuggers with
|
automatic_instalation = true,
|
||||||
-- reasonable debug configurations
|
|
||||||
automatic_installation = true,
|
|
||||||
|
|
||||||
-- You can provide additional configuration to the handlers,
|
|
||||||
-- see mason-nvim-dap README for more information
|
|
||||||
handlers = {},
|
handlers = {},
|
||||||
|
|
||||||
-- You'll need to check that you have the required things installed
|
|
||||||
-- online, please don't ask me how to install them :)
|
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
-- Update this to ensure that you have the debuggers for the langs you want
|
|
||||||
'delve',
|
'delve',
|
||||||
|
'python',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Dap UI setup
|
require('nvim-dap-virtual-text').setup {
|
||||||
-- For more information, see |:help nvim-dap-ui|
|
display_callback = function(variable)
|
||||||
dapui.setup {
|
local name = string.lower(variable.name)
|
||||||
-- Set icons to characters that are more likely to work in every terminal.
|
local value = string.lower(variable.value)
|
||||||
-- Feel free to remove or use ones that you like more! :)
|
if name:match 'secret' or name:match 'api' or value:match 'secret' or value:match 'api' then
|
||||||
-- Don't feel like these are good choices.
|
return '*****'
|
||||||
icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
|
end
|
||||||
controls = {
|
|
||||||
icons = {
|
if #variable.value > 15 then
|
||||||
pause = '⏸',
|
return ' ' .. string.sub(variable.value, 1, 15) .. '... '
|
||||||
play = '▶',
|
end
|
||||||
step_into = '⏎',
|
|
||||||
step_over = '⏭',
|
return ' ' .. variable.value
|
||||||
step_out = '⏮',
|
end,
|
||||||
step_back = 'b',
|
}
|
||||||
run_last = '▶▶',
|
|
||||||
terminate = '⏹',
|
-- Handled by nvim-dap-go
|
||||||
disconnect = '⏏',
|
-- 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
|
||||||
|
|
||||||
|
-- CodeLLDB debug adapter location
|
||||||
|
local codelldb = vim.fn.expand '$MASON/packages/codelldb'
|
||||||
|
local extension_path = codelldb .. '/extension/'
|
||||||
|
local codelldb_path = extension_path .. 'adapter/codelldb'
|
||||||
|
|
||||||
|
-- Configure the LLDB adapter
|
||||||
|
dap.adapters.codelldb = {
|
||||||
|
type = 'server',
|
||||||
|
port = '${port}',
|
||||||
|
executable = {
|
||||||
|
command = codelldb_path,
|
||||||
|
args = { '--port', '${port}' },
|
||||||
|
},
|
||||||
|
enrich_config = function(config, on_config)
|
||||||
|
-- If the configuration(s) in `launch.json` contains a `cargo` section
|
||||||
|
-- send the configuration off to the cargo_inspector.
|
||||||
|
if config['cargo'] ~= nil then
|
||||||
|
on_config(cargo_inspector(config))
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Configure LLDB adapter
|
||||||
|
dap.adapters.lldb = {
|
||||||
|
type = 'server',
|
||||||
|
port = '${port}',
|
||||||
|
executable = {
|
||||||
|
command = codelldb_path,
|
||||||
|
args = { '--port', '${port}' },
|
||||||
|
detached = false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Change breakpoint icons
|
-- Default debug configuration for C, C++
|
||||||
-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
|
dap.configurations.c = {
|
||||||
-- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
|
{
|
||||||
-- local breakpoint_icons = vim.g.have_nerd_font
|
name = 'Debug an Executable',
|
||||||
-- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
|
type = 'lldb',
|
||||||
-- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' }
|
request = 'launch',
|
||||||
-- for type, icon in pairs(breakpoint_icons) do
|
program = function()
|
||||||
-- local tp = 'Dap' .. type
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||||
-- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
|
end,
|
||||||
-- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
|
cwd = '${workspaceFolder}',
|
||||||
-- end
|
stopOnEntry = false,
|
||||||
|
|
||||||
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
|
|
||||||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
|
||||||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
|
||||||
|
|
||||||
-- Install golang specific config
|
|
||||||
require('dap-go').setup {
|
|
||||||
delve = {
|
|
||||||
-- On Windows delve must be run attached or it crashes.
|
|
||||||
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
|
|
||||||
detached = vim.fn.has 'win32' == 0,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dap.configurations.cpp = dap.configurations.c
|
||||||
|
dap.configurations.rust = {
|
||||||
|
{
|
||||||
|
name = 'Debug an Executable',
|
||||||
|
type = 'lldb',
|
||||||
|
request = 'launch',
|
||||||
|
program = function()
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
local default_binary = cwd .. '/target/debug/' .. vim.fn.fnamemodify(cwd, ':t')
|
||||||
|
return vim.fn.input('Path to executable: ', default_binary, 'file')
|
||||||
|
end,
|
||||||
|
cwd = '${workspaceFolder}',
|
||||||
|
stopOnEntry = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Override default configurations with `launch.json`
|
||||||
|
require('dap.ext.vscode').load_launchjs('.nvim/launch.json', { lldb = { 'c', 'cpp', 'rust' } })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<space>b', dap.toggle_breakpoint)
|
||||||
|
vim.keymap.set('n', '<space>gb', dap.run_to_cursor)
|
||||||
|
|
||||||
|
-- Eval var under cursor
|
||||||
|
vim.keymap.set('n', '<space>?', 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
|
||||||
|
|
||||||
|
require('dap-python').setup()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue