diff --git a/init.lua b/init.lua index a585457..ca22c16 100644 --- a/init.lua +++ b/init.lua @@ -1,12 +1,15 @@ --- Настройки +-- Settings require('settings/system') require('settings/tabs') require('settings/panels') require('settings/search') --- Плагины +-- Plugins require('plugins/packer') --- Комбинации клавиш +-- Keymaps require('keymaps/system') require('keymaps/plugins') + +-- Autocommands +require('autocommands') diff --git a/install.sh b/install.sh index 9dbba97..a2b0da6 100755 --- a/install.sh +++ b/install.sh @@ -62,6 +62,10 @@ if test (string match -ri "ru" "$LANG") set_color yellow; echo -n "[mirzaev/nvim] "; set_color blue; echo -n "[ЗАДАЧА] "; set_color white; echo "Установить форматировщик Prettier? (\"prettier/vim-prettier\") (y/N) "; case FORMATTER_PRETTIER_INSTALLED set_color yellow; echo -n "[mirzaev/nvim] "; set_color green; echo -n "[РАБОТА] "; set_color white; echo "Установлен форматировщик Prettier (\"prettier/vim-prettier\")"; + case PHP_DEBUG_ADAPTER_INSTALL + set_color yellow; echo -n "[mirzaev/nvim] "; set_color blue; echo -n "[ЗАДАЧА] "; set_color white; echo "Установить адаптер для отладки PHP? (\"xdebug/vscode-php-debug\") (y/N) "; + case PHP_DEBUG_ADAPTER_INSTALLED + set_color yellow; echo -n "[mirzaev/nvim] "; set_color green; echo -n "[РАБОТА] "; set_color white; echo "Установлен адаптер для отладки PHP (\"xdebug/vscode-php-debug\")"; case FONT_INSTALL set_color yellow; echo -n "[mirzaev/nvim] "; set_color blue; echo -n "[ЗАДАЧА] "; set_color white; echo "Установить шрифт "(set_color cyan)"FiraCode"(set_color white)"? (y/N) "; case FONT_INSTALLED @@ -121,6 +125,10 @@ else set_color yellow; echo -n "[mirzaev/nvim] "; set_color blue; echo -n "[TASK] "; set_color white; echo "Install the formatter Prettier? (\"prettier/vim-prettier\") (y/N) "; case FORMATTER_PRETTIER_INSTALLED set_color yellow; echo -n "[mirzaev/nvim] "; set_color green; echo -n "[WORK] "; set_color white; echo "Installed the formatter Prettier (\"prettier/vim-prettier\")"; + case PHP_DEBUG_ADAPTER_INSTALL + set_color yellow; echo -n "[mirzaev/nvim] "; set_color blue; echo -n "[TASK] "; set_color white; echo "Install the debug adapter for PHP? (\"xdebug/vscode-php-debug\") (y/N) "; + case PHP_DEBUG_ADAPTER_INSTALLED + set_color yellow; echo -n "[mirzaev/nvim] "; set_color green; echo -n "[WORK] "; set_color white; echo "Installed the debug-adapter for PHP (\"xdebug/vscode-php-debug\")"; case FONT_INSTALL set_color yellow; echo -n "[mirzaev/nvim] "; set_color blue; echo -n "[TASK] "; set_color white; echo "Install "(set_color cyan)"FiraCode"(set_color white)" font? (y/N) "; case FONT_INSTALLED @@ -370,6 +378,25 @@ if set -q _flag_force; or test (string match -ri 'y' "$RESPONSE") print FORMATTER_PRETTIER_INSTALLED end +if not set -q _flag_force + # Installation request + set RESPONSE (read -n 1 -p "print PHP_DEBUG_ADAPTER_INSTALL") + bind -e y +end + +if set -q _flag_force; or test (string match -ri 'y' "$RESPONSE") + # Accepted installation of "xdebug/vscode-php-debug" + + begin + cd ~/ + git clone https://github.com/xdebug/vscode-php-debug.git + cd vscode-php-debug + npm install && npm run build + end &> $output + + print PHP_DEBUG_ADAPTER_INSTALLED +end + print FONTS if not set -q _flag_force diff --git a/lua/autocommands.lua b/lua/autocommands.lua new file mode 100644 index 0000000..d47670c --- /dev/null +++ b/lua/autocommands.lua @@ -0,0 +1,10 @@ +vim.api.nvim_create_autocmd({'BufEnter','BufAdd','BufNew','BufNewFile','BufWinEnter'}, { + group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}), + callback = function() + -- Folding code method + -- vim.opt.foldmethod = 'expr' + + -- Expression for folding code + -- vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + end +}) diff --git a/lua/keymaps/plugins.lua b/lua/keymaps/plugins.lua index ddb4bc0..2feb60e 100644 --- a/lua/keymaps/plugins.lua +++ b/lua/keymaps/plugins.lua @@ -4,7 +4,7 @@ vim.keymap.set({ 'n', 'i', 'v', 't' }, '', 'Neotree toggle', { nore -- [[ folke/trouble.nvim ]] -vim.keymap.set({ 'n', 'i', 'v', 't' }, '', 'TroubleToggle', { noremap = true }) +vim.keymap.set({ 'n', 'i', 'v', 't' }, '', 'Trouble diagnostics toggle focus=false filter.buf=0', { noremap = true }) --[[ onsails/diaglist.nvim ]] @@ -123,6 +123,32 @@ vim.keymap.set('n', 'fb', builtin.buffers, { noremap = true, silent = tr vim.keymap.set('n', 'fh', builtin.help_tags, { noremap = true, silent = true }) +--[[ mfussenegger/nvim-dap ]] +vim.keymap.set('n', '', function() require('dap').continue() end) +vim.keymap.set('n', '', function() require('dap').step_over() end) +vim.keymap.set('n', '', function() require('dap').step_into() end) +vim.keymap.set('n', '', function() require('dap').step_out() end) +vim.keymap.set('n', 'b', function() require('dap').toggle_breakpoint() end) +vim.keymap.set('n', 'B', function() require('dap').set_breakpoint() end) +vim.keymap.set('n', 'lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) +vim.keymap.set('n', 'dr', function() require('dap').repl.open() end) +vim.keymap.set('n', 'dl', function() require('dap').run_last() end) +vim.keymap.set({'n', 'v'}, 'dh', function() + require('dap.ui.widgets').hover() +end) +vim.keymap.set({'n', 'v'}, 'dp', function() + require('dap.ui.widgets').preview() +end) +vim.keymap.set('n', 'df', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.frames) +end) +vim.keymap.set('n', 'ds', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.scopes) +end) + + --[[ windwp/nvim-autopairs ]] -- Переназначение стандартных сочетаний клавиш для "ms-jpq/coq_nvim" --vim.keymap.set('i', '', [[pumvisible() ? "" : ""]], {expr = true, noremap = true}) diff --git a/lua/plugins/dap-text.lua b/lua/plugins/dap-text.lua new file mode 100644 index 0000000..3489c51 --- /dev/null +++ b/lua/plugins/dap-text.lua @@ -0,0 +1,37 @@ +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/plugins/dap.lua b/lua/plugins/dap.lua index 9cd002a..7284166 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -1,2 +1,23 @@ -require('dap').configurations.cpp = { +-- Initialization +local dap = require('dap') + +-- Installing C, Rust and C++ +dap.configurations.cpp = { +} + +-- Initializing PHP adapter +dap.adapters.php = { + type = "executable", + command = "node", + args = { os.getenv("HOME") .. "/vscode-php-debug/out/phpDebug.js" } +} + +-- Installing PHP +dap.configurations.php = { + { + type = "php", + request = "launch", + name = "Listen for Xdebug", + port = 9003 + } } diff --git a/lua/plugins/dapui.lua b/lua/plugins/dapui.lua new file mode 100644 index 0000000..37ba8af --- /dev/null +++ b/lua/plugins/dapui.lua @@ -0,0 +1,19 @@ +require('dapui').setup() + +local dap, dapui = require("dap"), require("dapui") + +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end + +dap.listeners.before.launch.dapui_config = function() + dapui.open() +end + +dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() +end + +dap.listeners.before.event_exited.dapui_config = function() + dapui.close() +end diff --git a/lua/plugins/flexoki.lua b/lua/plugins/flexoki.lua new file mode 100644 index 0000000..a4c29f5 --- /dev/null +++ b/lua/plugins/flexoki.lua @@ -0,0 +1,77 @@ +-- Initializing +local flexoki = require('flexoki') + +-- Installing +flexoki.setup({ + variant = "auto", -- auto, moon, or dawn + dim_inactive_windows = false, + extend_background_behind_borders = true, + + enable = { + terminal = true, + }, + + styles = { + bold = true, + italic = false, + }, + + groups = { + border = "muted", + link = "purple_two", + panel = "surface", + + error = "red_one", + hint = "purple_one", + info = "cyan_one", + ok = "green_one", + warn = "orange_one", + note = "blue_one", + todo = "magenta_one", + + git_add = "green_one", + git_change = "yellow_one", + git_delete = "red_one", + git_dirty = "yellow_one", + git_ignore = "muted", + git_merge = "purple_one", + git_rename = "blue_one", + git_stage = "purple_one", + git_text = "magenta_one", + git_untracked = "subtle", + + h1 = "purple_two", + h2 = "cyan_two", + h3 = "magenta_two", + h4 = "orange_two", + h5 = "blue_two", + h6 = "cyan_two", + }, + + palette = { + -- Override the builtin palette per variant + -- moon = { + -- base = '#100f0f', + -- overlay = '#1c1b1a', + -- }, + }, + + highlight_groups = { + -- Comment = { fg = "subtle" }, + -- VertSplit = { fg = "muted", bg = "muted" }, + }, + + before_highlight = function(group, highlight, palette) + -- Disable all undercurls + -- if highlight.undercurl then + -- highlight.undercurl = false + -- end + -- + -- Change palette colour + -- if highlight.fg == palette.blue_two then + -- highlight.fg = palette.cyan_two + -- end + end,}) + +-- Activating +vim.cmd("colorscheme flexoki-moon") diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 071a009..18969d1 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -10,11 +10,12 @@ require('lualine').setup { }, ignore_focus = {}, always_divide_middle = true, + always_show_tabline = true, globalstatus = false, refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, + statusline = 100, + tabline = 100, + winbar = 100, } }, sections = { @@ -67,5 +68,5 @@ require('lualine').setup { tabline = {}, winbar = {}, inactive_winbar = {}, - extensions = {} + extensions = {'nvim-dap-ui', 'trouble', 'neo-tree'} } diff --git a/lua/plugins/packer.lua b/lua/plugins/packer.lua index 95590bd..a3850aa 100644 --- a/lua/plugins/packer.lua +++ b/lua/plugins/packer.lua @@ -5,6 +5,12 @@ return require('packer').startup(function(use) -- Менеджер плагинов Packer (автообновление) use 'wbthomason/packer.nvim' + -- Flexoki colorscheme + use { + 'nuvic/flexoki-nvim', + config = function() require('plugins/flexoki') end + } + -- Быстрая настройка LSP-серверов use { 'neovim/nvim-lspconfig', @@ -97,12 +103,6 @@ return require('packer').startup(function(use) -- Цвета для отображения найденных ошибок LSP-сервером в случае если другие цвета не найдены use 'folke/lsp-colors.nvim' - -- Клиентская реализация DAP - use { - 'mfussenegger/nvim-dap', - config = function() require('plugins/dap') end - } - -- Автозавершение use { 'ms-jpq/coq_nvim', @@ -133,19 +133,28 @@ return require('packer').startup(function(use) 'vim-test/vim-test', config = function() require('plugins/vim-test') end } + -- Functions for Telescope + use 'nvim-lua/plenary.nvim' - -- Интерфейс для поиска + -- DAP integration for Telescope + use 'nvim-telescope/telescope-dap.nvim' + + -- Fuzzy finder over lists (find, filter, preview, pick) use { 'nvim-telescope/telescope.nvim', - -- tag = '0.1.1', + tag = '0.1.8', + requires = {'nvim-lua/plenary.nvim'}, config = function() require('plugins/telescope') end } - -- Интеграция treesitter + -- UI for Treesitter use { 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - config = function() require('plugins/treesitter') end + config = function() require('plugins/treesitter') end, + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end } -- Удобное комментирование @@ -180,9 +189,31 @@ return require('packer').startup(function(use) -- Форматировщик Prettier use { - 'prettier/vim-prettier', - branch = 'master', - -- run = 'sudo npm i -g', - run = 'yarn install --frozen-lockfile --production' + 'prettier/vim-prettier', + branch = 'master', + -- run = 'sudo npm i -g', + run = 'yarn install --frozen-lockfile --production' } + + -- Debug Adapter Protocol client implementation -- + use { + 'mfussenegger/nvim-dap', + config = function() require('plugins/dap') end + } + + -- Asynchronous IO -- + use 'nvim-neotest/nvim-nio' + + -- UI for DAP client implementation -- + use { + 'rcarriga/nvim-dap-ui', + requires = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"}, + config = function() require('plugins/dapui') end + } + + -- Virtual text support for DAP client implementation and Treesitter -- + use { + 'theHamsta/nvim-dap-virtual-text', + config = function() require('plugins/dap-text') end + } end) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index a58ffc7..fdf0c5d 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,18 +1,27 @@ -require('telescope').setup{ +-- Initializing +local telescope = require('telescope'); + +-- Installing +telescope.setup { pickers = { - -- Default configuration for builtin pickers goes here: + -- Default configuration for builtin picikers goes here: -- picker_name = { - -- picker_config_key = value, + -- picker_configi_key = value, -- ... -- } -- Now the picker_config_key will be applied every time you call this -- builtin picker }, - extensions = { - -- Your extension configuration goes here: + + exteinsiions = { + -- Your extensioni configuration goes here: -- extension_name = { -- extension_config_key = value, -- } -- please take a look at the readme of the extension you want to configure + dap = {} } } + +-- Loading extensions +telescope.load_extension('dap') diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 4e29200..55da510 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,6 +1,7 @@ require('nvim-treesitter.configs').setup { highlight = { enable = true, - additional_vim_regex_highlighting = false + -- additional_vim_regex_highlighting = false + additional_vim_regex_highlighting = true }, } diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index 5a528ed..1ef5a51 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -46,3 +46,20 @@ require('trouble').setup({ }, use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client }) + +-- Initializing Telescope +local telescope = require("telescope") +local telescope_actions = require("telescope.actions") +local telescope_open = require("trouble.sources.telescope").open + +-- Use this to add more results without clearing the trouble list +local add_to_trouble = require("trouble.sources.telescope").add + +telescope.setup({ + defaults = { + mappings = { + i = { [""] = telescope_open }, + n = { [""] = telescope_open }, + }, + }, +}) diff --git a/lua/settings/panels.lua b/lua/settings/panels.lua index 8dbad99..7575cfa 100644 --- a/lua/settings/panels.lua +++ b/lua/settings/panels.lua @@ -3,3 +3,6 @@ vim.opt.splitright = true -- Горизонтальное разделение всегда вниз vim.opt.splitbelow = true + +-- Command line height +vim.opt.cmdheight = 0 diff --git a/lua/settings/system.lua b/lua/settings/system.lua index bee7aaf..6521854 100644 --- a/lua/settings/system.lua +++ b/lua/settings/system.lua @@ -25,7 +25,10 @@ vim.opt_local.wrap = true -- Отображение колонки курсора vim.opt_local.cursorcolumn = true --- Выбор цветовой темы +-- Theme +vim.opt.background = "dark" + +-- Colorscheme -- vim.cmd.colorscheme('default') -- vim.cmd.colorscheme('koehler') vim.cmd.colorscheme('vim')