diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua new file mode 100644 index 00000000..7ef2233f --- /dev/null +++ b/after/plugin/defaults.lua @@ -0,0 +1,107 @@ +vim.opt.relativenumber = true +vim.opt.cursorline = true +vim.opt.colorcolumn = '120' + +vim.keymap.set('n', 'e', ':NvimTreeToggle') +vim.keymap.set('n', 'f', ':NvimTreeFindFile') + + +-- indent via Tab +vim.keymap.set('n', '', '>>_') +vim.keymap.set('n', '', '<<_') +vim.keymap.set('v', '', '>>_') +vim.keymap.set('v', '', '<<_') +vim.keymap.set('i', '', '\t') +vim.keymap.set('i', '', '\b') + +-- Mapping U to Redo. +vim.keymap.set('', 'U', '') +vim.keymap.set('', '', '') + +vim.keymap.set('i', 'jk', '') +vim.keymap.set('i', 'kj', '') +vim.keymap.set('i', 'jj', '') +vim.keymap.set('i', 'kk', '') + +-- fast scrolling +vim.keymap.set('n', 'n', '20j') +vim.keymap.set('n', 'u', '20k') +vim.keymap.set('v', 'n', '20j') +vim.keymap.set('v', 'u', '20k') + + +-- Alternate way to save +vim.cmd('nnoremap :w!') +vim.cmd('inoremap :w!') + +-- Alternate way to quit +vim.cmd('nnoremap :q!') + + +-- ================= File management ================= -- + +-- swapfile has global & local config, eventhough help says otherwise +vim.o.swapfile = false -- can open already open files +vim.bo.swapfile = false +vim.o.backup = false +vim.o.writebackup = false +vim.o.autoread = true -- auto file change detection + +-- ================= Scrolling ================= -- + +vim.o.scrolloff = 999 -- start scrolling when 8 lines away from margins + +-- ================= Indentation ================= -- + +-- pay attention to 'vim.bo' (buffer local options) and 'vim.o' (global options) +-- see :help options.txt + +-- for some reason these values need to be set in both o and bo objects +-- eventhough these options are supposed to be local to buffer +vim.o.tabstop = 4 -- maximum width of tab character (measured in spaces) +vim.bo.tabstop = 4 +vim.o.shiftwidth = 4 -- size of indent (measured in spaces), should equal tabstop +vim.bo.shiftwidth = 4 +vim.o.softtabstop = 4 -- should be the same as the other two above +vim.bo.softtabstop = 4 +vim.o.expandtab = true -- expand tabs to spaces +vim.bo.expandtab = true -- expand tabs to spaces +vim.o.smartindent = true -- smart indenting on new line for C-like programs +vim.bo.smartindent = true +vim.o.autoindent = true -- copy the indentation from previous line +vim.bo.autoindent = true +vim.o.smarttab = true -- tab infront of a line inserts blanks based on shiftwidth + +-- ================= Search ================= -- + +vim.o.ignorecase = true -- Ignorecase when searching +vim.o.incsearch = true -- start searching on each keystroke +vim.o.smartcase = true -- ignore case when lowercase, match case when capital case is used +vim.o.hlsearch = true -- highlight the search results + +-- ================= Performance ================= -- + +vim.o.lazyredraw = true -- useful for when executing macros. +vim.o.ttimeoutlen = 10 -- ms to wait for a key code seq to complete + +-- ================= Misc ================= -- + +vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time +vim.wo.wrap = false -- don't wrap long text into multiple lines +vim.o.history = 10000 -- numbers of entries in history for ':' commands and search patterns (10000 = max) +vim.o.updatetime = 300 -- used for CursorHold event (for document highlighting detection) +vim.o.mouse = 'nv' -- allow mose in normal & visual mode + +-- better autocomplete behaviour +-- menuone - show popup menu also when there is only one match available +-- preview - show extra information about currently selected completion +-- noinsert - do not insert any text for match until the user selects it from the menu +vim.o.completeopt = 'menuone,preview,noinsert' + +-- allows hidden buffers +-- this means that a modified buffer doesn't need to be saved when changing +-- tabs/windows. +vim.o.hidden = true + +-- Copy paste between vim and everything else +vim.o.clipboard = "unnamedplus" diff --git a/init.lua b/init.lua index aeca6d28..9015a64e 100644 --- a/init.lua +++ b/init.lua @@ -353,7 +353,7 @@ require('nvim-treesitter.configs').setup { -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) -vim.keymap.set('n', 'e', vim.diagnostic.open_float) +-- vim.keymap.set('n', 'e', vim.diagnostic.open_float) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- LSP settings. @@ -384,7 +384,7 @@ local on_attach = function(_, bufnr) nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + -- nmap('K', vim.lsp.buf.hover, 'Hover Documentation') nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- Lesser used LSP functionality @@ -411,7 +411,7 @@ local servers = { -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, - -- tsserver = {}, + tsserver = {}, lua_ls = { Lua = { diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua new file mode 100644 index 00000000..10235d17 --- /dev/null +++ b/lua/custom/plugins/barbar.lua @@ -0,0 +1,10 @@ +return { + 'romgrk/barbar.nvim', + dependencies = 'nvim-tree/nvim-web-devicons', + config = function () + vim.keymap.set('', 'J', 'BufferPrevious') + vim.keymap.set('', 'K', 'BufferNext') + vim.keymap.set('', 'X', 'BufferClose') + end +} + diff --git a/lua/custom/plugins/colorscheme.lua b/lua/custom/plugins/colorscheme.lua new file mode 100644 index 00000000..948f117c --- /dev/null +++ b/lua/custom/plugins/colorscheme.lua @@ -0,0 +1,6 @@ +return { + "rmehri01/onenord.nvim", + config = function () + vim.cmd.colorscheme 'onenord' + end +} diff --git a/lua/custom/plugins/lspkind.lua b/lua/custom/plugins/lspkind.lua new file mode 100644 index 00000000..49f80738 --- /dev/null +++ b/lua/custom/plugins/lspkind.lua @@ -0,0 +1,26 @@ +return { + 'onsails/lspkind.nvim', + config = function () + + local lspkind = require'lspkind' + + -- nvim-cmp setup + local cmp = require 'cmp' + cmp.setup { + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + + -- The function below will be called before any actual modifications from lspkind + -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) + before = function (entry, vim_item) + return vim_item + end + }) + } + } + end +} + diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..c942e05d --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,41 @@ +return { + 'nvim-lualine/lualine.nvim', + opts = { +options = { + theme = 'onenord', + icons_enabled = true, + component_separators = {left = '', right = ''}, + section_separators = {left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + -- lualine_c = {'filename'}, + lualine_c = { + { + 'filename', + file_status = true, -- Displays file status (readonly status, modified status) + path = 1, -- 0: Just the filename + -- 1: Relative path + -- 2: Absolute path + + shorting_target = 40 -- Shortens path to leave 40 spaces in the window + -- for other components. (terrible name, any suggestions?) + } + }, + 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 = {} + }, + }, + } diff --git a/lua/custom/plugins/nvimtree.lua b/lua/custom/plugins/nvimtree.lua new file mode 100644 index 00000000..5a6842c9 --- /dev/null +++ b/lua/custom/plugins/nvimtree.lua @@ -0,0 +1,28 @@ +return { + 'nvim-tree/nvim-tree.lua', + requires = { + 'nvim-tree/nvim-web-devicons', -- optional, for file icons + }, + config = function () + local nvim_tree_events = require('nvim-tree.events') + local bufferline_api = require('bufferline.api') + + local function get_tree_size() + return require'nvim-tree.view'.View.width + end + + nvim_tree_events.subscribe('TreeOpen', function() + bufferline_api.set_offset(get_tree_size()) + end) + + nvim_tree_events.subscribe('Resize', function() + bufferline_api.set_offset(get_tree_size()) + end) + + nvim_tree_events.subscribe('TreeClose', function() + bufferline_api.set_offset(0) + end) + + require("nvim-tree").setup() + end +} diff --git a/lua/custom/plugins/startify.lua b/lua/custom/plugins/startify.lua new file mode 100644 index 00000000..40dd380c --- /dev/null +++ b/lua/custom/plugins/startify.lua @@ -0,0 +1,3 @@ +return { + 'mhinz/vim-startify' +}