1
0
Fork 0

Nvim configuration.

This commit is contained in:
Arthur Khachaturov 2023-12-01 19:05:24 +03:00
parent 8577646177
commit bb8a0eaec7
10 changed files with 61 additions and 37 deletions

View file

@ -4,12 +4,16 @@ vim.g.maplocalleader = ' '
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Load modules
require("utils.lazy").lazy_init()
require("lazy").setup("plugins", {
if vim.g.vscode then
require("config.mappings")
else
require("utils.lazy").lazy_init()
require("lazy").setup("plugins", {
change_detection = {
enabled = false,
notify = false,
},
})
})
require("config")
require("config")
end

View file

@ -1,5 +1,5 @@
require("config.options")
require("config.plugins")
require("config.mappings")
require("config.autocmd")
require("config.lsp")
require("config.mappings")
require("config.options")
require("config.plugins")

View file

@ -1,5 +1,8 @@
local map = vim.keymap.set
-- Unbind used keys
map('n', '<C-q>', '<NOP>')
-- Movements between splits
map('n', '<C-h>', '<C-w>h')
map('n', '<C-j>', '<C-w>j')
@ -16,14 +19,15 @@ map('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Exit buffers/nvim with <leader>
map("n", "<leader>q", function() require('utils.close_buffer').close_buffer() end)
map("n", "<leader><C-q>", function() require('utils.close_buffer').close_buffer(true) end)
map("n", "<leader>Q", ":%bd | quit<CR>")
map("n", "<leader><C-Q>", ":%bd! | quit!<CR>")
map("n", "<leader>w", ":write<CR>")
-- Copy and paste from clipboard
map("n", "<leader>y", '"+yy')
map("v", "<leader>y", '"+y')
map({ "n", "v" }, "<leader>p", '"+p')
map({ "n", "v" }, "<leader>P", '"+P')
-- Remap comments
map("n", "<C-_>", require("Comment.api").toggle.linewise.current)

View file

@ -1,5 +1,6 @@
require("config.plugins.treesitter")
require("config.plugins.telescope")
require("config.plugins.lualine")
require("config.plugins.nvim-autopairs")
require("config.plugins.nvim-cmp")
require("config.plugins.nvim-tree")
require("config.plugins.lualine")
require("config.plugins.telescope")
require("config.plugins.treesitter")

View file

@ -0,0 +1,4 @@
require('nvim-autopairs').setup({
disable_filetype = { "TelescopePrompt" , "vim" },
enable_check_bracket_line = false,
})

View file

@ -5,7 +5,10 @@ return {
'nvim-tree/nvim-web-devicons',
"nvim-tree/nvim-tree.lua",
'nvim-lualine/lualine.nvim',
'tpope/vim-surround',
'tmux-plugins/vim-tmux',
{ 'numToStr/Comment.nvim', opts = {} },
{ 'ethanholz/nvim-lastplace', config = {} },
{ "akinsho/bufferline.nvim", config = {} },
{ 'wakatime/vim-wakatime', event = 'VeryLazy' },
}

View file

@ -0,0 +1,5 @@
return {
'windwp/nvim-autopairs',
event = "InsertEnter",
opts = {}
}

View file

@ -1,22 +1,30 @@
local M = { }
function M.close_buffer()
local try_quit = function(command)
local function try_quit(command)
local success, errorMsg = pcall(vim.api.nvim_command, command)
if not success then
print("Failed to quit: " .. errorMsg)
end
end
function M.close_buffer(force)
local buf_cmd = "bd"
local quit_cmd = "qa"
if force then
buf_cmd = "bd!"
quit_cmd = "qa!"
end
local tree = require("nvim-tree.api").tree
local buffer_count = #vim.fn.filter(vim.fn.range(1, vim.fn.bufnr '$'), 'buflisted(v:val)')
if buffer_count ~= 1 then
tree.toggle({ focus = false })
try_quit("bd")
tree.toggle({ focus = false })
if buffer_count == 1 or buffer_count == 0 then
try_quit(quit_cmd)
else
try_quit("qa")
tree.toggle({ focus = false })
try_quit(buf_cmd)
tree.toggle({ focus = false })
end
end

View file

@ -1,4 +0,0 @@
return {
require("utils.lazy"),
require("utils.close_buffer"),
}

3
.gitignore vendored
View file

@ -1,4 +1,3 @@
# lazy.nvim lockfile
lazy-lock.json
**/tmux/plugins/
.config/tmux/plugins/
.zcompdump