diff --git a/.gitignore b/.gitignore index 005b535b606..34477f08fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ test.sh nvim spell/ -lazy-lock.json +# lazy-lock.json diff --git a/init.lua b/init.lua index 4eae8e7d95a..f08dfe1099e 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,4 @@ +require 'core.keymaps' --[[ ===================================================================== @@ -91,7 +92,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- 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 = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +103,9 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true +vim.opt.shiftwidth = 3 +vim.opt.tabstop = 3 -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -388,7 +391,7 @@ require('lazy').setup({ -- i = { ['<c-enter>'] = 'to_fuzzy_refine' }, -- }, -- }, - -- pickers = {} + picker = { hidden = true }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -616,7 +619,7 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, @@ -626,7 +629,7 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, + ts_ls = {}, -- lua_ls = { @@ -716,8 +719,11 @@ require('lazy').setup({ -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- + html = { 'htmlbeautifier' }, + css = { { 'prettierd', 'prettier' } }, + sass = { { 'prettierd', 'prettier' } }, -- 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 }, }, }, }, @@ -849,7 +855,7 @@ require('lazy').setup({ -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'tokyonight-moon' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' @@ -902,7 +908,24 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'css', + 'cpp', + 'javascript', + 'make', + 'cmake', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -921,7 +944,6 @@ require('lazy').setup({ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, - -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and -- place them in the correct locations. @@ -931,12 +953,12 @@ require('lazy').setup({ -- 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). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + 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` -- This is the easiest way to modularize your config. @@ -953,19 +975,19 @@ require('lazy').setup({ -- If you are using a Nerd Font: set icons to an empty table which will use the -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table icons = vim.g.have_nerd_font and {} or { - cmd = '⌘', - config = '🛠', - event = '📅', - ft = '📂', - init = '⚙', - keys = '🗝', - plugin = '🔌', - runtime = '💻', - require = '🌙', - source = '📄', - start = '🚀', - task = '📌', - lazy = '💤 ', + -- cmd = '⌘', + -- config = '🛠', + -- event = '📅', + -- ft = '📂', + -- init = '⚙', + -- keys = '🗝', + -- plugin = '🔌', + -- runtime = '💻', + -- require = '🌙', + -- source = '📄', + -- start = '🚀', + -- task = '📌', + -- lazy = '💤 ', }, }, }) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..7ecf7574c26 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,39 @@ +{ + "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "8c354323201d04530727d8bdcc4669791ee082ef" }, + "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, + "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, + "indent-blankline.nvim": { "branch": "master", "commit": "7871a88056f7144defca9c931e311a3134c5d509" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "7b4d5d48b6b5a75009d63f8f3e4ef4819b7e8139" }, + "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, + "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, + "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, + "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, + "nvim-dap-go": { "branch": "main", "commit": "6aa88167ea1224bcef578e8c7160fe8afbb44848" }, + "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, + "nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" }, + "nvim-lspconfig": { "branch": "master", "commit": "4cb925e96288a71409a86c84fd97f4434a95453e" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-treesitter": { "branch": "master", "commit": "bb06afa3f1111780932b3c5493ad65473ce85f9d" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "tokyonight.nvim": { "branch": "main", "commit": "ce91ba480070c95f40753e4663e32b4632ac6db3" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" } +} diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua new file mode 100644 index 00000000000..206050cf68e --- /dev/null +++ b/lua/core/keymaps.lua @@ -0,0 +1,11 @@ +local opts = { noremap = true, silent = true } + +--Resize with arrows +vim.keymap.set('n', '<Up>', ':resize +2<CR>', opts) +vim.keymap.set('n', '<Down>', ':resize -2<CR>', opts) +vim.keymap.set('n', '<Left>', ':vertical resize -2<CR>', opts) +vim.keymap.set('n', '<Right>', ':vertical resize +2<CR>', opts) + +--Stay in indent mode +vim.keymap.set('v', '<', '<gv', opts) +vim.keymap.set('v', '>', '>gv', opts) diff --git a/lua/custom/plugins/ftplugin/cpp.lua b/lua/custom/plugins/ftplugin/cpp.lua new file mode 100644 index 00000000000..33276fa3e7d --- /dev/null +++ b/lua/custom/plugins/ftplugin/cpp.lua @@ -0,0 +1,4 @@ +vim.bo.tabstop = 3 -- size of a hard tabstop (ts). +vim.bo.shiftwidth = 3 -- size of an indentation (sw). +vim.bo.expandtab = true -- always uses spaces instead of tab characters (et). +vim.bo.softtabstop = 3 -- number of spaces a <Tab> counts for. When 0, feature is off (sts). diff --git a/lua/custom/plugins/ftplugin/js.lua b/lua/custom/plugins/ftplugin/js.lua new file mode 100644 index 00000000000..33276fa3e7d --- /dev/null +++ b/lua/custom/plugins/ftplugin/js.lua @@ -0,0 +1,4 @@ +vim.bo.tabstop = 3 -- size of a hard tabstop (ts). +vim.bo.shiftwidth = 3 -- size of an indentation (sw). +vim.bo.expandtab = true -- always uses spaces instead of tab characters (et). +vim.bo.softtabstop = 3 -- number of spaces a <Tab> counts for. When 0, feature is off (sts). diff --git a/lua/custom/plugins/nvim-tree.lua b/lua/custom/plugins/nvim-tree.lua new file mode 100644 index 00000000000..0513d818879 --- /dev/null +++ b/lua/custom/plugins/nvim-tree.lua @@ -0,0 +1,6 @@ +return { + 'nvim-tree/nvim-tree.lua', + keys = { + { 'n', '<leader>e', ':NvimTreeToggle<CR>', { silent = true } }, + }, +} diff --git a/lua/custom/plugins/surround.lua b/lua/custom/plugins/surround.lua new file mode 100644 index 00000000000..e32286cc534 --- /dev/null +++ b/lua/custom/plugins/surround.lua @@ -0,0 +1,10 @@ +return { + 'kylechui/nvim-surround', + version = '*', -- Use for stability; omit to use `main` branch for the latest features + event = 'VeryLazy', + config = function() + require('nvim-surround').setup { + -- Configuration here, or leave empty to use defaults + } + end, +} diff --git a/lua/custom/plugins/virtualtext.lua b/lua/custom/plugins/virtualtext.lua new file mode 100644 index 00000000000..f026dad566a --- /dev/null +++ b/lua/custom/plugins/virtualtext.lua @@ -0,0 +1,42 @@ +return { + 'theHamsta/nvim-dap-virtual-text', + dependencies = { + 'hrsh7th/nvim-cmp', + 'mfussenegger/nvim-dap', + 'nvim-treesitter/nvim-treesitter', + }, + require('nvim-dap-virtual-text').setup { + enabled = true, -- enable this plugin (the default) + enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) + highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText + highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) + show_stop_reason = true, -- show stop reason when stopped for exceptions + commented = false, -- prefix virtual text with comment string + only_first_definition = true, -- only show virtual text at first definition (if there are multiple) + all_references = false, -- show virtual text on all all references of the variable (not only definitions) + clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping) + --- A callback that determines how a variable is displayed or whether it should be omitted + --- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable + --- @param buf number + --- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame + --- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`) + --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text + --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed + display_callback = function(variable, buf, stackframe, node, options) + -- by default, strip out new line characters + if options.virt_text_pos == 'inline' then + return ' = ' .. variable.value:gsub('%s+', ' ') + else + return variable.name .. ' = ' .. variable.value:gsub('%s+', ' ') + end + end, + -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line + virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol', + + -- experimental features: + all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine. + virt_lines = false, -- show virtual lines instead of virtual text (will flicker!) + virt_text_win_col = nil, -- position the virtual text at a fixed window column (starting from the first text column) , + -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()` + }, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 753cb0cedd3..46dbfb1e9a1 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -13,7 +13,7 @@ return { dependencies = { -- Creates a beautiful debugger UI 'rcarriga/nvim-dap-ui', - + 'theHamsta/nvim-dap-virtual-text', -- Required dependency for nvim-dap-ui 'nvim-neotest/nvim-nio', @@ -97,26 +97,92 @@ return { 'delve', }, } - + --GDB + dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + command = 'C:/Users/18196/.vscode/extensions/ms-vscode.cpptools-1.23.1-win32-x64/debugAdapters/bin/OpenDebugAD7.exe', + options = { + detached = false, + }, + } + dap.configurations.cpp = { + { + name = 'Launch file', + type = 'cppdbg', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = 'Attach to gdbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'gdb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/gdb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + }, + } -- 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 = '⏏', - }, + -- icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + -- controls = { + -- icons = { + -- pause = '⏸', + -- play = '▶', + -- step_into = '⏎', + -- step_over = '⏭', + -- step_out = '⏮', + -- step_back = 'b', + -- run_last = '▶▶', + -- terminate = '⏹', + -- disconnect = '⏏', + -- }, + -- }, + } + + --GDB config + dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + command = 'C:Users/A/.vscode/extensions/ms-vscode.cpptools-1.23.1-win32-x64/debugAdapters/bin/OpenDebugAD7.exe', + options = { + detached = false, + }, + } + dap.configurations.cpp = { + { + name = 'Launch file', + type = 'cppdbg', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = 'Attach to gdbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'gdb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/gdb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, }, }