diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..998724c --- /dev/null +++ b/init.lua @@ -0,0 +1,13 @@ +require("initializer") +vim.opt.mouse = "c" -- set mouse in command line mode +vim.opt.colorcolumn = "80" -- highlight this column +vim.opt.relativenumber = true +vim.opt.number = true +vim.opt.clipboard = "unnamedplus" -- synchronize with system clipboard +vim.opt.swapfile = false +vim.opt.cursorline = true +vim.opt.termguicolors = true +vim.cmd [[ + highlight clear + colorscheme dracula +]] diff --git a/init.vim b/init.vim deleted file mode 100644 index 9203b5e..0000000 --- a/init.vim +++ /dev/null @@ -1,62 +0,0 @@ -" load main lua file with additional configs -lua require("initializer") - -" highlight all .conf files as apache config (:]) -autocmd BufEnter *.conf :setlocal filetype=apache -"au BufNewFile,BufRead *.sls set filetype=sls.yaml -"nerdtree bindings -nnoremap n :NvimTreeFocus -nnoremap :NvimTreeToggle - -" nerdcommenter custom bindings -nmap NERDCommenterToggle -vmap NERDCommenterToggle - -set termguicolors -highlight clear -colorscheme dracula - -set splitright -set splitbelow - - -" indent/unindent with tab/shift-tab -nmap >> -nmap << -imap < >gv -vmap ff Telescope find_files -nnoremap fg Telescope live_grep -nnoremap fb Telescope buffers -nnoremap fh Telescope help_tags - -" general configs -set modeline -set encoding=UTF-8 -set showmatch " show matching -set ignorecase " case insensitive -set mouse=v " middle-click paste with -set hlsearch " highlight search -set incsearch " incremental search -set tabstop=4 " number of columns occupied by a tab -set softtabstop=4 " see multiple spaces as tabstops so does the right thing -set expandtab " converts tabs to white space -set shiftwidth=4 " width for autoindents -set autoindent " indent a new line the same amount as the line just typed -set number " add line numbers -set relativenumber " add relative line numbers -set wildmode=longest,list " get bash-like tab completions -set cc=80 " set an 80 column border for good coding style -filetype plugin indent on "allow auto-indenting depending on file type -syntax on " syntax highlighting -"set mouse=a " enable mouse click -set clipboard+=unnamedplus " using system clipboard -filetype plugin on -set cursorline " highlight current cursorline -set ttyfast " Speed up scrolling in Vim -" set spell " enable spell check (may need to download language package) -set noswapfile " disable creating swap file -" set backupdir=~/.cache/vim " Directory to store backup files. diff --git a/lua/conf-nvim-tree.lua b/lua/conf-nvim-tree.lua index f77f98b..1f69797 100644 --- a/lua/conf-nvim-tree.lua +++ b/lua/conf-nvim-tree.lua @@ -1,7 +1,5 @@ require("nvim-tree").setup({ hijack_cursor = true, - open_on_setup = true, - open_on_setup_file = true, sync_root_with_cwd = true, view = { adaptive_size = true, diff --git a/lua/config-noice.lua b/lua/config-noice.lua new file mode 100644 index 0000000..7f60d65 --- /dev/null +++ b/lua/config-noice.lua @@ -0,0 +1,38 @@ +return { + config = { + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + hover = { + enabled = true, + view = nil, -- when nil, use defaults from documentation + ---@type NoiceViewOptions + opts = {}, -- merged with defaults from documentation + }, + signature = { + enabled = false, + auto_open = { + enabled = true, + trigger = true, -- Automatically show signature help when typing a trigger character from the LSP + luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes + throttle = 50, -- Debounce lsp signature help request by 50ms + }, + view = nil, -- when nil, use defaults from documentation + ---@type NoiceViewOptions + opts = {}, -- merged with defaults from documentation + }, + } +} diff --git a/lua/general.lua b/lua/general.lua index b1398c9..3cbb179 100644 --- a/lua/general.lua +++ b/lua/general.lua @@ -12,3 +12,33 @@ codewindow.setup({ z_index = 1, -- The z-index the floating window will be on }) codewindow.apply_default_keybinds() + +local function open_nvim_tree() + + -- open the tree + require("nvim-tree.api").tree.open() +end + +-- Functional wrapper for mapping custom keybindings +local function map(mode, lhs, rhs, opts) + local options = { noremap = true } + if opts then + options = vim.tbl_extend("force", options, opts) + end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +---------------------- +-- general setup start +---------------------- + +-- open nvim tree on start +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + +-- tab lines in normal and visual mode +map("n", "", ">>") +map("n", "", "<<") +map("i", "", "<", ">>") +map("v", "", ">gv") +map("v", "", "n", "NvimTreeFocus" }, + { "", "NvimTreeToggle" } + } }, -- neovim lsp plugins and depencencies { 'neovim/nvim-lspconfig' }, @@ -28,58 +32,26 @@ require("lazy").setup({ { 'lewis6991/gitsigns.nvim' }, { 'petertriho/nvim-scrollbar' }, { 'kevinhwang91/nvim-hlslens' }, - { 'L3MON4D3/LuaSnip', version = '*' }, + { 'L3MON4D3/LuaSnip', version = '*' }, { 'saadparwaiz1/cmp_luasnip' }, { 'lambdalisue/suda.vim' }, - { 'akinsho/bufferline.nvim', version = '*' }, + { 'akinsho/bufferline.nvim', version = '*' }, { 'gorbit99/codewindow.nvim' }, - { 'preservim/nerdcommenter' }, + { 'preservim/nerdcommenter', + keys = { + { "", "NERDCommenterToggle", mode = "v" }, + { "", "NERDCommenterToggle", mode = "n" } + } }, { 'rmagatti/auto-session' }, { 'tpope/vim-fugitive' }, { 'Glench/Vim-Jinja2-Syntax' }, { 'vmware-archive/salt-vim' }, { 'stephpy/vim-yaml' }, { 'lukas-reineke/indent-blankline.nvim' }, - { 'rcarriga/nvim-notify' }, { 'MunifTanjim/nui.nvim' }, { 'folke/noice.nvim', - config = { - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, - hover = { - enabled = true, - view = nil, -- when nil, use defaults from documentation - ---@type NoiceViewOptions - opts = {}, -- merged with defaults from documentation - }, - signature = { - enabled = false, - auto_open = { - enabled = true, - trigger = true, -- Automatically show signature help when typing a trigger character from the LSP - luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes - throttle = 50, -- Debounce lsp signature help request by 50ms - }, - view = nil, -- when nil, use defaults from documentation - ---@type NoiceViewOptions - opts = {}, -- merged with defaults from documentation - }, - }, dependencies = { + config = require("config-noice").config, "MunifTanjim/nui.nvim", -- OPTIONAL: -- `nvim-notify` is only needed, if you want to use the notification view. @@ -104,10 +76,17 @@ require("lazy").setup({ { 'projekt0n/github-nvim-theme' }, --Fuzzy search by Telescope and its dependencies: - { 'nvim-lua/plenary.nvim' }, { 'nvim-telescope/telescope.nvim', branch = 'master', - dependencies = { 'nvim-lua/plenary.nvim' } + dependencies = { 'nvim-lua/plenary.nvim' }, + keys = { + { "ff", "Telescope find_files" }, + { "fg", "Telescope live_grep" }, + { "fb", "Telescope buffers" }, + { "fh", "Telescope help_tags" } + + } + }, { 'BurntSushi/ripgrep' }, { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' },