diff options
Diffstat (limited to '')
| -rw-r--r-- | nvim/init.lua | 1 | ||||
| -rw-r--r-- | nvim/lua/autocommands.lua | 34 | ||||
| -rw-r--r-- | nvim/lua/colors.lua | 39 | ||||
| -rw-r--r-- | nvim/lua/keymaps.lua | 25 | ||||
| -rw-r--r-- | nvim/lua/plugins/init.lua | 32 | ||||
| -rw-r--r-- | zsh/zshrc | 149 |
6 files changed, 151 insertions, 129 deletions
diff --git a/nvim/init.lua b/nvim/init.lua index 988f88a..e62059f 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -16,3 +16,4 @@ require("keymaps") require("autocommands") require("lsp") require("dap") +require("colors") diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua index ef7353f..d9edd27 100644 --- a/nvim/lua/autocommands.lua +++ b/nvim/lua/autocommands.lua @@ -77,24 +77,6 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "FileReadPost" }, { }) vim.api.nvim_create_autocmd("BufEnter", { - pattern = "*", - callback = function() - vim.defer_fn(function() - vim.cmd("normal! zR") - end, 100) - end, -}) - -vim.api.nvim_create_autocmd("BufWinEnter", { - pattern = "*", - callback = function() - vim.schedule(function() - vim.cmd("normal! zR") - end) - end, -}) - -vim.api.nvim_create_autocmd("BufEnter", { callback = function() if vim.bo.filetype == "NvimTree" or vim.fn.expand("%") == "" then return @@ -117,6 +99,22 @@ vim.api.nvim_create_autocmd({ "BufWritePost" }, { end, }) +-- Автоматический вход в insert mode при открытии терминала +vim.api.nvim_create_autocmd({ "BufWinEnter", "WinEnter" }, { + pattern = "term://*", + callback = function() + vim.cmd("startinsert") + end, +}) + +-- Автоматический выход из insert mode при уходе с терминала +vim.api.nvim_create_autocmd("BufLeave", { + pattern = "term://*", + callback = function() + vim.cmd("stopinsert") + end, +}) + -- vim.api.nvim_create_autocmd("InsertEnter", { -- pattern = "*", -- command = "set norelativenumber", diff --git a/nvim/lua/colors.lua b/nvim/lua/colors.lua new file mode 100644 index 0000000..e5d90ef --- /dev/null +++ b/nvim/lua/colors.lua @@ -0,0 +1,39 @@ +require("onedark").setup({ + style = "darker", + transparent = false, -- Show/hide background + term_colors = true, -- Change terminal color as per the selected theme style + ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden + cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu + + -- toggle theme style --- + toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts" + toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between + + -- Change code style --- + -- Options are italic, bold, underline, none + -- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold' + code_style = { + comments = "italic", + keywords = "none", + functions = "none", + strings = "none", + variables = "none", + }, + + -- Lualine options -- + lualine = { + transparent = false, -- lualine center bar transparency + }, + + -- Custom Highlights -- + colors = {}, -- Override default colors + highlights = {}, -- Override highlight groups + + -- Plugins Config -- + diagnostics = { + darker = true, -- darker colors for diagnostic + undercurl = true, -- use undercurl instead of underline for diagnostics + background = true, -- use background color for virtual text + }, +}) +require("onedark").load() diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 6a1640d..455e5fd 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -15,13 +15,19 @@ map("i", "<End>", "<C-o>$", { noremap = true, silent = true }) -- Фикс для визуального режима map("v", "i", "<S-i>", { noremap = true, silent = true }) map("v", "a", "<S-a>", { noremap = true, silent = true }) +map("v", "J", ":m '>+1<CR>gv=gv", { noremap = true, silent = true }) +map("v", "K", ":m '<-2<CR>gv=gv", { noremap = true, silent = true }) +map("v", "<", "<gv", { noremap = true, silent = true }) +map("v", ">", ">gv", { noremap = true, silent = true }) -- Управление буферами -- kmap("n", "<leader>bn", "<cmd>bnext<CR>", { noremap = true, silent = true, desc = "Next buffer" }) kmap("n", "<leader>bp", "<cmd>bprevious<CR>", { noremap = true, silent = true, desc = "Previous buffer" }) kmap("n", "<leader>bd", "<cmd>bdelete<CR>", { noremap = true, silent = true, desc = "Delete buffer" }) kmap("n", "<leader>w", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" }) -kmap("n", "qq", "<cmd>q<CR>") +kmap("n", "qq", "<cmd>q<CR>", { noremap = true, silent = true, desc = "Exit" }) +kmap("n", "<leader>vs", "<cmd>vsplit<CR>", { noremap = true, silent = true, desc = "Vertical split" }) + -- Управление вкладками -- kmap("n", "<A-Right>", ":tabnext<CR>", { noremap = true, silent = true, desc = "Next tab" }) kmap("n", "<A-Left>", ":tabprevious<CR>", { noremap = true, silent = true, desc = "Previous tab" }) @@ -35,19 +41,20 @@ end -- Файловый менеджер -- kmap("n", "<F3>", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" }) -kmap("n", "<leader>tt", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" }) +-- kmap("n", "<leader>tt", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" }) +kmap("n", "<leader>tt", ":split<CR>:terminal<CR>:startinsert<CR>", { noremap = true, silent = true }) -- Поиск с Telescope -- kmap("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { noremap = true, silent = true, desc = "Find files" }) kmap("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", { noremap = true, silent = true, desc = "Live grep" }) kmap("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { noremap = true, silent = true, desc = "Find buffers" }) +kmap("n", "<leader>fe", "<cmd>Telescope file_browser<CR>", { noremap = true, silent = true, desc = "File browser" }) -- LSP функции -- kmap("n", "<leader>e", vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Show diagnostics" }) -kmap("n", "[d", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" }) -kmap("n", "]d", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" }) -kmap("n", "<leader>q", vim.diagnostic.setloclist, { noremap = true, silent = true, desc = "Add to location list" }) +kmap("n", "d[", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" }) +kmap("n", "d]", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" }) kmap("n", "gD", vim.lsp.buf.declaration, { noremap = true, silent = true, desc = "Go to declaration" }) kmap("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true, desc = "Go to definition" }) @@ -88,7 +95,12 @@ end) kmap("n", "<F12>", function() require("dap").step_out() end) -kmap("n", "<leader>dt", "<cmd>lua require'dapui'.toggle()<CR>", { noremap = true, silent = true, desc = "Toggle debug UI" }) +kmap( + "n", + "<leader>dt", + "<cmd>lua require'dapui'.toggle()<CR>", + { noremap = true, silent = true, desc = "Toggle debug UI" } +) kmap("n", "<leader>dc", function() require("dap").continue() end) @@ -102,7 +114,6 @@ kmap("n", "<leader>st", function() require("dap").step_out() end) - kmap("n", "<Leader>b", function() require("dap").toggle_breakpoint() end) diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index b27e33f..0c3e6a5 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -3,15 +3,7 @@ return require("packer").startup({ use("wbthomason/packer.nvim") use("nvim-lua/plenary.nvim") use("neovim/nvim-lspconfig") - use({ - "srt0/codescope.nvim", - config = function() - require("codescope").setup({ - transparent = false, -- Set to true for transparency - }) - vim.cmd.colorscheme("codescope") - end, - }) + use("navarasu/onedark.nvim") use("Snyssfx/goerr-nvim") use({ "lukas-reineke/indent-blankline.nvim", @@ -22,26 +14,6 @@ return require("packer").startup({ use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, - config = function() - local dap, dapui = require("dap"), require("dapui") - dapui.setup() - dap.listeners.before.attach.dapui_config = function() - dapui.open() - vim.cmd(":NvimTreeClose<CR>") - end - dap.listeners.before.launch.dapui_config = function() - dapui.open() - vim.cmd(":NvimTreeClose<CR>") - end - dap.listeners.before.event_terminated.dapui_config = function() - dapui.close() - vim.cmd(":NvimTreeOpen<CR>") - end - dap.listeners.before.event_exited.dapui_config = function() - dapui.close() - vim.cmd(":NvimTreeOpen<CR>") - end - end, }) use({ "leoluz/nvim-dap-go", @@ -76,11 +48,13 @@ return require("packer").startup({ require("plugins.treesitter") end, }) + use({ "nvim-telescope/telescope-file-browser.nvim" }) use({ "nvim-telescope/telescope.nvim", config = function() require("plugins.telescope") end, + requires = "nvim-lua/plenary.nvim", }) use({ "nvim-tree/nvim-tree.lua", @@ -49,7 +49,7 @@ alias cp="cp -i" alias gitpush="git add . && git commit --amend --no-edit && git push -f" alias yu="ssh-add -e /usr/lib/x86_64-linux-gnu/libykcs11.so; ssh-add -s /usr/lib/x86_64-linux-gnu/libykcs11.so" alias n="nvim" -alias n.="nvim ." +alias nv="nvim ." alias cp="cp -i" alias df="df -h" alias free="free -m" @@ -104,14 +104,84 @@ WORDCHARS=${WORDCHARS//\/[&.;]} autoload -U compinit colors zcalc compinit -d +# Runs before showing the prompt +function mzc_termsupport_precmd { + [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return + title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE +} + +# Runs before executing the command +function mzc_termsupport_preexec { + [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return + + emulate -L zsh + + # split command into array of arguments + local -a cmdargs + cmdargs=("${(z)2}") + # if running fg, extract the command from the job description + if [[ "${cmdargs[1]}" = fg ]]; then + # get the job id from the first argument passed to the fg command + local job_id jobspec="${cmdargs[2]#%}" + # logic based on jobs arguments: + # http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs + # https://www.zsh.org/mla/users/2007/msg00704.html + case "$jobspec" in + <->) # %number argument: + # use the same <number> passed as an argument + job_id=${jobspec} ;; + ""|%|+) # empty, %% or %+ argument: + # use the current job, which appears with a + in $jobstates: + # suspended:+:5071=suspended (tty output) + job_id=${(k)jobstates[(r)*:+:*]} ;; + -) # %- argument: + # use the previous job, which appears with a - in $jobstates: + # suspended:-:6493=suspended (signal) + job_id=${(k)jobstates[(r)*:-:*]} ;; + [?]*) # %?string argument: + # use $jobtexts to match for a job whose command *contains* <string> + job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;; + *) # %string argument: + # use $jobtexts to match for a job whose command *starts with* <string> + job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;; + esac + + # override preexec function arguments with job command + if [[ -n "${jobtexts[$job_id]}" ]]; then + 1="${jobtexts[$job_id]}" + 2="${jobtexts[$job_id]}" + fi + fi + + # cmd name only, or if this is sudo or ssh, the next cmd + local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} + local LINE="${2:gs/%/%%}" + + title '$CMD' '%100>...>$LINE%<<' +} + +# Emits the control sequence to notify many terminal emulators +# of the cwd +# +# Identifies the directory using a file: URI scheme, including +# the host name to disambiguate local vs. remote paths. +function mzc_termsupport_cwd { + # Percent-encode the host and path names. + local URL_HOST URL_PATH + URL_HOST="$(zsh_urlencode -P $HOST)" || return 1 + URL_PATH="$(zsh_urlencode -P $PWD)" || return 1 + + # common control sequence (OSC 7) to set current host and path + printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}" +} autoload -U add-zsh-hook -#add-zsh-hook precmd mzc_termsupport_precmd -#add-zsh-hook preexec mzc_termsupport_preexec +add-zsh-hook precmd mzc_termsupport_precmd +add-zsh-hook preexec mzc_termsupport_preexec # Use a precmd hook instead of a chpwd hook to avoid contaminating output # i.e. when a script or function changes directory without `cd -q`, chpwd # will be called the output may be swallowed by the script or function. -#add-zsh-hook precmd mzc_termsupport_cwd +add-zsh-hook precmd mzc_termsupport_cwd source ~/.config/zsh/conf.d/*.zsh @@ -223,62 +293,6 @@ function title { ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~" -# Runs before showing the prompt -function mzc_termsupport_precmd { - [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return - title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE -} - -# Runs before executing the command -function mzc_termsupport_preexec { - [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return - - emulate -L zsh - - # split command into array of arguments - local -a cmdargs - cmdargs=("${(z)2}") - # if running fg, extract the command from the job description - if [[ "${cmdargs[1]}" = fg ]]; then - # get the job id from the first argument passed to the fg command - local job_id jobspec="${cmdargs[2]#%}" - # logic based on jobs arguments: - # http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs - # https://www.zsh.org/mla/users/2007/msg00704.html - case "$jobspec" in - <->) # %number argument: - # use the same <number> passed as an argument - job_id=${jobspec} ;; - ""|%|+) # empty, %% or %+ argument: - # use the current job, which appears with a + in $jobstates: - # suspended:+:5071=suspended (tty output) - job_id=${(k)jobstates[(r)*:+:*]} ;; - -) # %- argument: - # use the previous job, which appears with a - in $jobstates: - # suspended:-:6493=suspended (signal) - job_id=${(k)jobstates[(r)*:-:*]} ;; - [?]*) # %?string argument: - # use $jobtexts to match for a job whose command *contains* <string> - job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;; - *) # %string argument: - # use $jobtexts to match for a job whose command *starts with* <string> - job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;; - esac - - # override preexec function arguments with job command - if [[ -n "${jobtexts[$job_id]}" ]]; then - 1="${jobtexts[$job_id]}" - 2="${jobtexts[$job_id]}" - fi - fi - - # cmd name only, or if this is sudo or ssh, the next cmd - local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} - local LINE="${2:gs/%/%%}" - - title '$CMD' '%100>...>$LINE%<<' -} - # URL-encode a string # # Encodes a string using RFC 2396 URL-encoding (%-escaped). @@ -352,21 +366,6 @@ function zsh_urlencode() { echo -E "$url_str" } -# Emits the control sequence to notify many terminal emulators -# of the cwd -# -# Identifies the directory using a file: URI scheme, including -# the host name to disambiguate local vs. remote paths. -function mzc_termsupport_cwd { - # Percent-encode the host and path names. - local URL_HOST URL_PATH - URL_HOST="$(zsh_urlencode -P $HOST)" || return 1 - URL_PATH="$(zsh_urlencode -P $PWD)" || return 1 - - # common control sequence (OSC 7) to set current host and path - printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}" -} - if [ -f env.sh ]; then source ./env.sh fi |
