This commit is contained in:
Krzysiek Wyka 2024-08-28 20:23:53 +02:00
parent 6dcec70791
commit 6fcff31577
11 changed files with 189 additions and 101 deletions

View File

@ -85,6 +85,9 @@ vim.o.confirm = true
-- Clear highlights on search when pressing <Esc> in normal mode -- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch` -- See `:help hlsearch`
-- Spell checking
vim.opt.spell = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps -- Diagnostic keymaps
@ -121,6 +124,8 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
-- [[ Basic Autocommands ]] -- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands` -- See `:help lua-guide-autocommands`
-- Save on upper W
vim.api.nvim_create_user_command('W', 'w', {})
-- Highlight when yanking (copying) text -- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode -- Try it with `yap` in normal mode
@ -214,6 +219,7 @@ require('lazy').setup({
{ -- Useful plugin to show you pending keybinds. { -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim', 'folke/which-key.nvim',
version = '2.1.0',
event = 'VimEnter', -- Sets the loading event to 'VimEnter' event = 'VimEnter', -- Sets the loading event to 'VimEnter'
opts = { opts = {
-- delay between pressing a key and opening which-key (milliseconds) -- delay between pressing a key and opening which-key (milliseconds)
@ -687,6 +693,7 @@ require('lazy').setup({
-- --
-- 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 },
json = { { 'prettier' } },
javascript = { { 'prettier' } }, javascript = { { 'prettier' } },
typescript = { { 'prettier' } }, typescript = { { 'prettier' } },
}, },

View File

@ -0,0 +1,8 @@
return {
{
'm4xshen/autoclose.nvim',
config = function()
require('autoclose').setup()
end,
},
}

View File

@ -0,0 +1,12 @@
return {
{
'utilyre/barbecue.nvim',
name = 'barbecue',
version = '*',
dependencies = {
'SmiteshP/nvim-navic',
'nvim-tree/nvim-web-devicons',
},
opts = {},
},
}

View File

@ -0,0 +1,58 @@
return {
{
'ThePrimeagen/harpoon',
branch = 'harpoon2',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local harpoon = require 'harpoon'
harpoon:setup {}
vim.keymap.set('n', '<leader>a', function()
harpoon:list():add()
end, { desc = 'Harpoon add' })
local function toggle_telescope(harpoon_files)
local finder = function()
local paths = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(paths, item.value)
end
return require('telescope.finders').new_table {
results = paths,
}
end
require('telescope.pickers')
.new({}, {
prompt_title = 'Harpoon',
finder = finder(),
previewer = false,
sorter = require('telescope.config').values.generic_sorter {},
layout_config = {
height = 0.4,
width = 0.5,
prompt_position = 'top',
preview_cutoff = 120,
},
attach_mappings = function(prompt_bufnr, map)
map('i', '<C-d>', function()
local state = require 'telescope.actions.state'
local selected_entry = state.get_selected_entry()
local current_picker = state.get_current_picker(prompt_bufnr)
table.remove(harpoon_files.items, selected_entry.index)
current_picker:refresh(finder())
end)
return true
end,
})
:find()
end
vim.keymap.set('n', '<leader>sm', function()
toggle_telescope(harpoon:list())
end, { desc = 'Harpon list' })
end,
},
}

View File

@ -1,10 +0,0 @@
return {
{
'ysmb-wtsg/in-and-out.nvim',
config = function()
vim.keymap.set('i', '<C-CR>', function()
require('in-and-out').in_and_out()
end)
end,
},
}

View File

@ -7,66 +7,28 @@ return {
j = { j = {
name = '[J]ester', name = '[J]ester',
s = { s = {
function() name = '[S]ingle test',
jester.run()
end,
'[S]ingle test',
}, },
f = { f = {
function() name = '[F]ile test',
jester.run_file()
end,
'[F]ile test',
}, },
-- s = {
-- name = '[S]ingle test',
-- r = {
-- function()
-- jester.run()
-- end,
-- '[R]un',
-- },
-- d = {
-- function()
-- jester.debug()
-- end,
-- '[D]ebug',
-- },
-- ['1'] = 'which_key_ignore',
-- },
-- f = {
-- name = '[F]ile test',
-- r = {
-- function()
-- jester.run_file()
-- end,
-- '[R]un',
-- },
-- d = {
-- function()
-- jester.debug_file()
-- end,
-- '[D]ebug',
-- },
-- ['1'] = 'which_key_ignore',
-- },
['1'] = 'which_key_ignore', ['1'] = 'which_key_ignore',
}, },
}, { prefix = '<leader>' }) }, { prefix = '<leader>' })
jester.setup { jester.setup {
cmd = "npm t -- -t '$result' $file", -- run command cmd = "npm t -- -t '$result' $file",
identifiers = { 'test', 'it' }, -- used to identify tests identifiers = { 'test', 'it' },
prepend = { 'describe' }, -- prepend describe blocks prepend = { 'describe' },
expressions = { 'call_expression' }, -- tree-sitter object used to scan for tests/describe blocks expressions = { 'call_expression' },
path_to_jest_run = 'jest', -- used to run tests path_to_jest_run = 'jest',
path_to_jest_debug = './node_modules/.bin/jest', -- used for debugging path_to_jest_debug = './node_modules/.bin/jest',
terminal_cmd = ':vsplit | terminal', -- used to spawn a terminal for running tests, for debugging refer to nvim-dap's config terminal_cmd = ':vsplit | terminal',
dap = { -- debug adapter configuration dap = {
type = 'node2', type = 'pwa-node',
request = 'launch', request = 'launch',
cwd = vim.fn.getcwd(), cwd = vim.fn.getcwd(),
runtimeArgs = { '--inspect-brk', '$path_to_jest', '--no-coverage', '-t', '$result', '--', '$file' }, runtimeArgs = { '--inspect-brk', '~/n/bin/npm', 't', '--', '--no-coverage', '-t', '$result', '--', '$file' },
args = { '--no-cache' }, args = { '--no-cache' },
sourceMaps = false, sourceMaps = false,
protocol = 'inspector', protocol = 'inspector',
@ -77,10 +39,10 @@ return {
}, },
} }
vim.keymap.set('n', '<leader>js', jester.run, { desc = 'Single test Run' }) vim.keymap.set('n', '<leader>jsr', jester.run, { desc = 'Single test Run' })
-- vim.keymap.set('n', '<leader>jsd', jester.debug, { desc = 'Single test debug' }) vim.keymap.set('n', '<leader>jsd', jester.debug, { desc = 'Single test debug' })
vim.keymap.set('n', '<leader>jf', jester.run, { desc = 'File test Run' }) vim.keymap.set('n', '<leader>jfr', jester.run, { desc = 'File test Run' })
-- vim.keymap.set('n', '<leader>jfd', jester.debug, { desc = 'File test debug' }) vim.keymap.set('n', '<leader>jfd', jester.debug, { desc = 'File test debug' })
end, end,
}, },
} }

View File

@ -0,0 +1,13 @@
return {
{
'AckslD/nvim-neoclip.lua',
dependencies = {
{ 'nvim-telescope/telescope.nvim' },
},
config = function()
require('neoclip').setup()
vim.keymap.set('n', '<leader>sv', ':Telescope neoclip<CR>', { desc = 'Yank history' })
end,
},
}

View File

@ -0,0 +1,17 @@
return {
{
'NeogitOrg/neogit',
tag = 'v0.0.1',
dependencies = {
'nvim-lua/plenary.nvim',
'sindrets/diffview.nvim',
'nvim-telescope/telescope.nvim',
},
opts = {
integrations = {
telescope = true,
diffview = true,
},
},
},
}

View File

@ -0,0 +1,15 @@
return {
{
'folke/noice.nvim',
event = 'VeryLazy',
opts = {
messages = {
enabled = false,
},
},
dependencies = {
'MunifTanjim/nui.nvim',
'rcarriga/nvim-notify',
},
},
}

View File

@ -0,0 +1,16 @@
return {
{
'KrzysiekWyka/workspace.nvim',
dependencies = { 'nvim-telescope/telescope.nvim' },
config = function()
require('workspace').setup {
workspaces = {
{ name = 'Work', path = '~/development/nodejs/work', keymap = { '<leader>w' } },
},
}
local workspace = require 'workspace'
vim.keymap.set('n', '<leader>ps', workspace.tmux_sessions)
end,
},
}

View File

@ -99,9 +99,13 @@ return {
ensure_installed = { ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want -- Update this to ensure that you have the debuggers for the langs you want
'delve', 'delve',
'js',
}, },
} }
-- Read .vscode/launch.json
require('dap.ext.vscode').load_launchjs(nil, {})
-- Basic debugging keymaps, feel free to change to your liking! -- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' }) vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' }) vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
@ -153,48 +157,34 @@ return {
dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close
require('dap-vscode-js').setup { dap.adapters['pwa-node'] = {
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node" type = 'server',
debugger_path = vim.fn.stdpath 'data' .. '/lazy/vscode-js-debug', host = '::1',
-- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`. port = '${port}',
adapters = { 'pwa-node', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost', 'node' }, -- which adapters to register in nvim-dap executable = {
-- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging command = 'js-debug-adapter',
-- log_file_level = false -- Logging level for output to file. Set to false to disable file logging. args = { '${port}' },
-- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output. },
} }
local js_based_languages = { 'typescript', 'javascript' } local js_based_languages = { 'typescript', 'javascript' }
for _, language in ipairs(js_based_languages) do for _, language in ipairs(js_based_languages) do
require('dap').configurations[language] = { dap.configurations[language] = {
{ -- {
type = 'pwa-node', -- type = 'pwa-node',
request = 'launch', -- request = 'launch',
name = 'Launch file', -- name = 'Launch file',
program = '${file}', -- program = '${file}',
cwd = '${workspaceFolder}', -- cwd = '${workspaceFolder}',
}, -- },
{ -- {
type = 'pwa-node', -- type = 'pwa-node',
request = 'attach', -- request = 'attach',
name = 'Attach', -- name = 'Attach',
processId = require('dap.utils').pick_process, -- processId = require('dap.utils').pick_process,
cwd = '${workspaceFolder}', -- cwd = '${workspaceFolder}',
}, -- }
{
type = 'pwa-node',
request = 'launch',
name = 'Debug Jest Tests',
env = { NODE_OPTIONS = '--experimental-vm-modules', ENV = 'test' },
runtimeExecutable = 'node',
runtimeArgs = {
'./node_modules/jest/bin/jest.js',
},
rootPath = '${workspaceFolder}',
cwd = '${workspaceFolder}',
console = 'integratedTerminal',
internalConsoleOptions = 'neverOpen',
},
} }
end end
end, end,