From 0e899fe8ed478993f345a9b561dfcacca057e440 Mon Sep 17 00:00:00 2001 From: janusz Date: Mon, 6 Nov 2023 15:27:23 +0100 Subject: [PATCH] missing files --- lua/lua/custom/plugins/harpoon.lua | 27 +++ lua/lua/custom/plugins/init.lua | 49 +++++ lua/lua/custom/plugins/keymap.lua | 32 ++++ lua/lua/custom/plugins/neoformat.lua | 10 + lua/lua/custom/plugins/tree.lua | 226 +++++++++++++++++++++++ lua/lua/custom/plugins/undotree.lua | 5 + lua/lua/kickstart/plugins/autoformat.lua | 74 ++++++++ lua/lua/kickstart/plugins/debug.lua | 87 +++++++++ 8 files changed, 510 insertions(+) create mode 100644 lua/lua/custom/plugins/harpoon.lua create mode 100644 lua/lua/custom/plugins/init.lua create mode 100644 lua/lua/custom/plugins/keymap.lua create mode 100644 lua/lua/custom/plugins/neoformat.lua create mode 100644 lua/lua/custom/plugins/tree.lua create mode 100644 lua/lua/custom/plugins/undotree.lua create mode 100644 lua/lua/kickstart/plugins/autoformat.lua create mode 100644 lua/lua/kickstart/plugins/debug.lua diff --git a/lua/lua/custom/plugins/harpoon.lua b/lua/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..74adc086 --- /dev/null +++ b/lua/lua/custom/plugins/harpoon.lua @@ -0,0 +1,27 @@ +return { + 'ThePrimeagen/harpoon', + config = function() + local mark = require("harpoon.mark") + local ui = require("harpoon.ui") + + vim.keymap.set('n', "aa", mark.add_file, { desc = 'add file to list' }) + vim.keymap.set('n', "al", ui.toggle_quick_menu, { desc = 'quick list' }) + vim.keymap.set('n', "ap", ui.nav_prev) + vim.keymap.set('n', "an", ui.nav_next) + + vim.keymap.set('n', "", function() + ui.nav_file(1) + end) + vim.keymap.set('n', "", function() + ui.nav_file(2) + end) + + vim.keymap.set('n', "", function() + ui.nav_file(3) + end) + + vim.keymap.set('n', "", function() + ui.nav_file(4) + end) + end, +} diff --git a/lua/lua/custom/plugins/init.lua b/lua/lua/custom/plugins/init.lua new file mode 100644 index 00000000..5e9c3cd9 --- /dev/null +++ b/lua/lua/custom/plugins/init.lua @@ -0,0 +1,49 @@ +-- 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 + +vim.opt.guicursor = +"n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175" + +-- vim.opt.guicursor = "" + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +-- vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +-- vim.opt.isfname:append("@_@") + +vim.opt.colorcolumn = "80" + +vim.opt.showtabline = 2 + +function my_tabline() + local s = '' + for i = 1, vim.fn.tabpagenr('$') do + local bufnr = vim.fn.tabpagebuflist(i)[vim.fn.tabpagewinnr(i)] + local bufname = vim.fn.fnamemodify(vim.fn.bufname(bufnr), ':p') + s = s .. '%' .. i .. 'T' .. (bufnr == vim.fn.bufnr('%') and '%1*' or '%2*') .. bufname .. ' ' + end + return s +end + +vim.o.tabline = [[%!v:lua.my_tabline()]] + +return {} diff --git a/lua/lua/custom/plugins/keymap.lua b/lua/lua/custom/plugins/keymap.lua new file mode 100644 index 00000000..fd15193c --- /dev/null +++ b/lua/lua/custom/plugins/keymap.lua @@ -0,0 +1,32 @@ +vim.keymap.set('n', 'w', 'w', { desc = 'Write file' }) +vim.keymap.set('n', '', 'h', { desc = 'Window left' }) +vim.keymap.set('n', '', 'l', { desc = 'Window right' }) +vim.keymap.set('n', '', 'j', { desc = 'Window down' }) +vim.keymap.set('n', '', 'k', { desc = 'Window up' }) + +vim.keymap.set('i', '', '', { desc = 'Move left' }) +vim.keymap.set('i', '', '', { desc = 'Move right' }) + +vim.keymap.set('n', 'c', 'q', { desc = 'Move right' }) + +vim.keymap.set('n', '', ":m .+1==") +vim.keymap.set('n', '', ":m .-2==") + +vim.keymap.set('i', '', ":m .-2==gi") +vim.keymap.set('i', '', ":m .+1==gi") + +vim.keymap.set('v', '', ":m '>+1gv-gv") +vim.keymap.set('v', '', ":m '<-2gv-gv") + +vim.keymap.set('n', 'J', "mzJ`z") + +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') + +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') + +vim.keymap.set('x', 'p', "\"_dP") + + +return {} diff --git a/lua/lua/custom/plugins/neoformat.lua b/lua/lua/custom/plugins/neoformat.lua new file mode 100644 index 00000000..19936ce9 --- /dev/null +++ b/lua/lua/custom/plugins/neoformat.lua @@ -0,0 +1,10 @@ +vim.g.neoformat_try_node_exe = 1 + +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = { "*.json", "*.jsonc", "*.js", "*.ts", "*.tsx", "*.jsx" }, + command = "silent Neoformat prettier", +}) + +return { + "sbdchd/neoformat", +} diff --git a/lua/lua/custom/plugins/tree.lua b/lua/lua/custom/plugins/tree.lua new file mode 100644 index 00000000..46da2cbd --- /dev/null +++ b/lua/lua/custom/plugins/tree.lua @@ -0,0 +1,226 @@ +-- disable netrw at the very start of your init.lua +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true + +vim.keymap.set('n', 'e', 'NvimTreeToggle') + + +function on_text_search() + local api = require("nvim-tree.api") + local node = api.tree.get_node_under_cursor() + + vim.cmd("Telescope live_grep search_dirs=" .. node.absolute_path) +end + +function folder_search(bufnr) + local api = require("nvim-tree.api") + api.config.mappings.default_on_attach(bufnr) + + vim.api.nvim_buf_set_keymap( + bufnr, + "n", + "st", + "lua on_text_search()", + { silent = false, nowait = true } + ) +end + +function NvimTreeWidth() + local winwidth = vim.fn.winwidth(0) + if winwidth <= 100 then + return 30 + elseif winwidth <= 200 then + return 40 + else + return 50 + end +end + +return { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + opts = { + on_attach = folder_search, + + auto_reload_on_write = false, + disable_netrw = false, + hijack_cursor = false, + hijack_netrw = true, + hijack_unnamed_buffer_when_opening = false, + sort_by = "name", + root_dirs = {}, + prefer_startup_root = false, + sync_root_with_cwd = true, + reload_on_bufenter = false, + respect_buf_cwd = false, + select_prompts = false, + view = { + adaptive_size = false, + centralize_selection = true, + width = NvimTreeWidth(), + hide_root_folder = false, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + float = { + enable = false, + quit_on_focus_loss = true, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, + }, + }, + }, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = true, + full_name = false, + highlight_opened_files = "none", + root_folder_label = ":t", + indent_width = 2, + indent_markers = { + enable = false, + inline_arrows = true, + icons = { + corner = "└", + edge = "│", + item = "│", + none = " ", + }, + }, + special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" }, + symlink_destination = true, + }, + hijack_directories = { + enable = false, + auto_open = true, + }, + update_focused_file = { + enable = true, + debounce_delay = 15, + update_root = true, + ignore_list = {}, + }, + -- diagnostics = { + -- enable = lvim.use_icons, + -- show_on_dirs = false, + -- show_on_open_dirs = true, + -- debounce_delay = 50, + -- severity = { + -- min = vim.diagnostic.severity.HINT, + -- max = vim.diagnostic.severity.ERROR, + -- }, + -- icons = { + -- hint = lvim.icons.diagnostics.BoldHint, + -- info = lvim.icons.diagnostics.BoldInformation, + -- warning = lvim.icons.diagnostics.BoldWarning, + -- error = lvim.icons.diagnostics.BoldError, + -- }, + -- }, + filters = { + dotfiles = false, + git_clean = false, + no_buffer = false, + -- custom = { "node_modules", "\\.cache" }, + custom = { "\\.cache" }, + exclude = {}, + }, + filesystem_watchers = { + enable = true, + debounce_delay = 50, + ignore_dirs = {}, + }, + git = { + enable = true, + ignore = false, + show_on_dirs = true, + show_on_open_dirs = true, + timeout = 200, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, + }, + expand_all = { + max_folder_discovery = 300, + exclude = {}, + }, + file_popup = { + open_win_config = { + col = 1, + row = 1, + relative = "cursor", + border = "shadow", + style = "minimal", + }, + }, + open_file = { + quit_on_open = false, + resize_window = false, + window_picker = { + enable = true, + picker = "default", + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, + }, + remove_file = { + close_window = true, + }, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + live_filter = { + prefix = "[FILTER]: ", + always_show_folders = true, + }, + tab = { + sync = { + open = false, + close = false, + ignore = {}, + }, + }, + notify = { + threshold = vim.log.levels.INFO, + }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + dev = false, + diagnostics = false, + git = false, + profile = false, + watcher = false, + }, + }, + system_open = { + cmd = nil, + args = {}, + }, + }, +} diff --git a/lua/lua/custom/plugins/undotree.lua b/lua/lua/custom/plugins/undotree.lua new file mode 100644 index 00000000..5daf5dab --- /dev/null +++ b/lua/lua/custom/plugins/undotree.lua @@ -0,0 +1,5 @@ +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) + +return { + 'mbbill/undotree' +} diff --git a/lua/lua/kickstart/plugins/autoformat.lua b/lua/lua/kickstart/plugins/autoformat.lua new file mode 100644 index 00000000..bc56b15b --- /dev/null +++ b/lua/lua/kickstart/plugins/autoformat.lua @@ -0,0 +1,74 @@ +-- autoformat.lua +-- +-- Use your language server to automatically format your code on save. +-- Adds additional commands as well to manage the behavior + +return { + 'neovim/nvim-lspconfig', + config = function() + -- Switch for controlling whether you want autoformatting. + -- Use :KickstartFormatToggle to toggle autoformatting on or off + local format_is_enabled = true + vim.api.nvim_create_user_command('KickstartFormatToggle', function() + format_is_enabled = not format_is_enabled + print('Setting autoformatting to: ' .. tostring(format_is_enabled)) + end, {}) + + -- Create an augroup that is used for managing our formatting autocmds. + -- We need one augroup per client to make sure that multiple clients + -- can attach to the same buffer without interfering with each other. + local _augroups = {} + local get_augroup = function(client) + if not _augroups[client.id] then + local group_name = 'kickstart-lsp-format-' .. client.name + local id = vim.api.nvim_create_augroup(group_name, { clear = true }) + _augroups[client.id] = id + end + + return _augroups[client.id] + end + + -- Whenever an LSP attaches to a buffer, we will run this function. + -- + -- See `:help LspAttach` for more information about this autocmd event. + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), + -- This is where we attach the autoformatting for reasonable clients + callback = function(args) + local client_id = args.data.client_id + local client = vim.lsp.get_client_by_id(client_id) + local bufnr = args.buf + + -- Only attach to clients that support document formatting + if not client.server_capabilities.documentFormattingProvider then + return + end + + -- Tsserver usually works poorly. Sorry you work with bad languages + -- You can remove this line if you know what you're doing :) + if client.name == 'tsserver' then + return + end + + -- Create an autocmd that will run *before* we save the buffer. + -- Run the formatting command for the LSP that has just attached. + vim.api.nvim_create_autocmd('BufWritePre', { + group = get_augroup(client), + buffer = bufnr, + callback = function() + if not format_is_enabled then + return + end + + vim.lsp.buf.format { + async = false, + filter = function(c) + return c.id == client.id + end, + } + end, + }) + end, + }) + end, +} diff --git a/lua/lua/kickstart/plugins/debug.lua b/lua/lua/kickstart/plugins/debug.lua new file mode 100644 index 00000000..7fc783fa --- /dev/null +++ b/lua/lua/kickstart/plugins/debug.lua @@ -0,0 +1,87 @@ +-- debug.lua +-- +-- Shows how to use the DAP plugin to debug your code. +-- +-- Primarily focused on configuring the debugger for Go, but can +-- be extended to other languages as well. That's why it's called +-- kickstart.nvim and not kitchen-sink.nvim ;) + +return { + -- NOTE: Yes, you can install new plugins here! + 'mfussenegger/nvim-dap', + -- NOTE: And you can specify dependencies as well + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/nvim-dap-ui', + + -- Installs the debug adapters for you + 'williamboman/mason.nvim', + 'jay-babu/mason-nvim-dap.nvim', + + -- Add your own debuggers here + 'leoluz/nvim-dap-go', + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_setup = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + 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 = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, + } + + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', 'B', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'Debug: Set Breakpoint' }) + + -- Dap UI setup + -- For more information, see |:help nvim-dap-ui| + dapui.setup { + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + } + + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) + + 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() + end, +}