diff --git a/init.lua b/init.lua index fd4567d9..0eb8d2c4 100644 --- a/init.lua +++ b/init.lua @@ -682,3 +682,9 @@ cmp.setup { -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- +-- custom settings +require("custom.configs.settings") + +-- custom mappings +require("custom.configs.maps") diff --git a/lua/custom/configs/maps.lua b/lua/custom/configs/maps.lua new file mode 100644 index 00000000..4863c215 --- /dev/null +++ b/lua/custom/configs/maps.lua @@ -0,0 +1,51 @@ +local function map(mode, lhs, rhs) + vim.keymap.set(mode, lhs, rhs, { silent = true }) +end + +-- Save +map("n", "w", "update") + +-- Quit +map("n", "q", "q") + +-- Exit insert mode +map("i", "jj", "") + +-- Window split +map("n", "sv", "vsplit") +map("n", "sh", "split") + +-- Window resize +map("n", "", "<") +map("n", "", ">") +map("n", "", "+") +map("n", "", "-") + +-- Move selected line / block of text in visual mode +map("v", "J", ":m '>+1gv=gv") +map("v", "K", ":m '<-2gv-gv") + +map("n", "J", "mzJ`z") +map("n", "", "zz") +map("n", "", "zz") +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- Buffer +map("n", "", "bnext") +map("n", "", "bprevious") + +map("n", "Q", "") +map("n", "", "silent !tmux new tmux-sessionizer") + +-- LSP format +map("n", "f", function() + vim.lsp.buf.format() +end) + +-- Search and replace +map("n", "s", [[:%s/\<\>//gI]]) + + +-- Reset highlight +map("n", "", "noh") diff --git a/lua/custom/configs/settings.lua b/lua/custom/configs/settings.lua new file mode 100644 index 00000000..eebf351e --- /dev/null +++ b/lua/custom/configs/settings.lua @@ -0,0 +1,40 @@ +local global = vim.g +local o = vim.o + +-- Copilot +global.copilot_assume_mapped = true + +-- Editor options +o.relativenumber = true +o.syntax = 'on' +o.autoindent = true +o.cursorline = true +o.expandtab = true +o.shiftwidth = 2 +o.tabstop = 2 +o.encoding = 'utf-8' +o.ruler = true +o.title = true +o.hidden = true +o.wildmenu = true +o.showcmd = true +o.showmatch = true +o.inccommand = 'split' +o.splitbelow = true -- open new vertical split bottom +o.splitright = true -- open new horizontal split right +o.smartindent = true +o.wrap = false + +-- Highlight search +o.hlsearch = true +o.incsearch = true + +-- No vim backup files +o.backup = false +o.swapfile = false + +-- Scrolling settings +o.scrolloff = 8 +o.colorcolumn = '80' + + diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..0bc50063 --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,3 @@ +return { + "github/copilot.vim" +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..340ed713 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,15 @@ +return { + 'thePrimeagen/harpoon', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function () + local mark = require('harpoon.mark') + vim.keymap.set("n", "ha", mark.add_file) + + local ui = require('harpoon.ui') + vim.keymap.set("n", "", ui.toggle_quick_menu) + 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/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..6b89a746 --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,45 @@ +return { + { + 'nvim-lualine/lualine.nvim', + opts = { + options = { + icons_enabled = true, + theme = 'onedark', + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, + }, + }, +} diff --git a/lua/custom/plugins/mardown_preview.lua b/lua/custom/plugins/mardown_preview.lua new file mode 100644 index 00000000..447d2c2c --- /dev/null +++ b/lua/custom/plugins/mardown_preview.lua @@ -0,0 +1,9 @@ +return { + "iamcco/markdown-preview.nvim", + config = function() + vim.fn["mkdp#util#install"]() + + vim.keymap.set("n", "m", "MarkdownPreview") + vim.keymap.set("n", "mn", "MarkdownPreviewStop") + end, +} diff --git a/lua/custom/plugins/neo-tree.lua b/lua/custom/plugins/neo-tree.lua index 4b2717e0..ae51dd89 100644 --- a/lua/custom/plugins/neo-tree.lua +++ b/lua/custom/plugins/neo-tree.lua @@ -13,5 +13,7 @@ return { }, config = function () require('neo-tree').setup {} + vim.keymap.set("n", "nt", "Neotree toggle") + vim.keymap.set("n", "o", "Neotree focus") end } diff --git a/lua/custom/plugins/toggleterm.lua b/lua/custom/plugins/toggleterm.lua new file mode 100644 index 00000000..9835a1f3 --- /dev/null +++ b/lua/custom/plugins/toggleterm.lua @@ -0,0 +1,24 @@ +return { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + local term = require('toggleterm') + + term.setup { + size = 20, + open_mapping = [[tf]], + shading_factor = 2, + direction = 'float', + float_opts = { + border = 'curved', + highlights = { + border = "Normal", + background = "Normal", + } + }, + } + + vim.keymap.set("n", "th", "ToggleTerm size=10 direction=horizontal") + vim.keymap.set("n", "tv", "ToggleTerm size=80 direction=vertical") + end +} diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua new file mode 100644 index 00000000..0f5f0893 --- /dev/null +++ b/lua/custom/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + 'mbbill/undotree', + config =function () + vim.keymap.set("n", "u", "UndotreeToggle") + end +}