diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2024-04-26 20:57:53 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2024-04-27 13:35:37 +0200 |
commit | 1d99ee5817a962643378f4049bb3d1fbc025bf65 (patch) | |
tree | 75afb5b4ff4cd3d351ebba2ddc2cbd74c942fbe6 /Common/nvim/lua | |
parent | 6aa68a6c85788defa42c6fc03fdd5b2dcc1b1b48 (diff) | |
download | dotfiles-1d99ee5817a962643378f4049bb3d1fbc025bf65.tar.gz dotfiles-1d99ee5817a962643378f4049bb3d1fbc025bf65.zip |
Simplify neovim
Diffstat (limited to 'Common/nvim/lua')
-rwxr-xr-x | Common/nvim/lua/basic.lua | 193 | ||||
-rwxr-xr-x | Common/nvim/lua/helper_functions.lua | 25 | ||||
-rw-r--r-- | Common/nvim/lua/lsp-conf.lua | 16 | ||||
-rwxr-xr-x | Common/nvim/lua/plugins.lua | 79 |
4 files changed, 66 insertions, 247 deletions
diff --git a/Common/nvim/lua/basic.lua b/Common/nvim/lua/basic.lua index 275deed..7633e40 100755 --- a/Common/nvim/lua/basic.lua +++ b/Common/nvim/lua/basic.lua @@ -1,202 +1,53 @@ --[[ -General + General --]] --- Lines of history -vim.opt.history = 500 --- Line numbers -vim.opt.nu = false - --- Autoread when file is changed outside vim vim.opt.autoread = true - --- Convenient sudo saving of file -vim.api.nvim_create_user_command( - 'W', 'w !sudo tee % > /dev/null', - {bang=true, desc='Save file using sudo'} -) - --- Disable the auto line wrap vim.opt.formatoptions:remove("t") - --- Make find more usefull vim.opt.path:append("**") - --- Turn off netrw banner vim.g.netrw_banner = 0 --- Tree style listing in netrw -vim.g.netrw_liststyle = 1 --- Make browse set split --- vim.g.netrw_browse_split = 4 --- Split to the right, instead of to the left --- vim.g.netrw_altv = 1 - ---[[ -VIM User interface ---]] - --- Set 3 lines to the cursor - when moving vertically using j/k --- vim.opt.so = 3 - --- set WildMenu ---vim.opt.wildmenu = true - --- Ignore compiled files -vim.opt.wildignore = '*.o,*~,*.pyc' -vim.opt.wildignore:append('*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store') - --- Always show current position ---vim.opt.ruler = true - --- Hide buffers when they are abandoned --- vim.opt.hid = true - --- Make backspace function normally -vim.opt.backspace = 'eol,start,indent' -vim.opt.whichwrap:append('<,>,h,l') - --- Ignore case when searching -vim.opt.ignorecase = true - --- Be smart about cases when searching --- If search has uppercases, then we want to respect case +vim.opt.wildignore = '*.o,*~,*.pyc,*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store' vim.opt.smartcase = true - --- Highlight search results -vim.opt.hlsearch = true - --- Make search act like search in modern browsers -vim.opt.incsearch = true - --- Turn on "magic" for regular expressions -vim.opt.magic = true - --- Show matching brackets when cursor is over one vim.opt.showmatch = true -vim.opt.mat = 2 - --- Left column option, used to have it at 1 to always show it. But Gitsigns is not using it anyway -vim.opt.foldcolumn = '0' - --- Show leader commands -vim.opt.showcmd = true - --- Colorscheme -vim.cmd [[ colorscheme default ]] -vim.opt.background = "light" -vim.opt.termguicolors = true --- No idea why, preview in fzf does at least work extremely porly without this -vim.cmd [[ let $BAT_THEME = 'gruvbox-light' ]] - --- Workaround for gutter color, to remove background? -vim.api.nvim_set_hl(0, "SignColumn", {link = "LineNr"}) -vim.api.nvim_create_autocmd("ColorScheme", { - pattern = "*", - callback = function() - vim.api.nvim_set_hl(0, "SignColumn", {link = "LineNr"}) - end -}) - --- Show colour column -vim.opt.colorcolumn = '80,120' -vim.api.nvim_set_hl(0, "ColorColumn", { ctermbg = "lightgrey", bg = "#eae7da" }) - --- Set utf8 as standard encoding -vim.opt.encoding = 'utf8' - --- Use Unix as the standard file type -vim.opt.ffs = 'unix,dos,mac' - ---[[ -Files, backups and undo ---]] vim.opt.swapfile = false +vim.opt.smartindent = true --[[ -Text, tab and indent related + Convenience stuff --]] --- Use spaces instead of tabs -vim.opt.expandtab = true - --- Be smart when using tabs -vim.opt.smarttab = true - --- 1 tab is 4 spaces +-- Default to the "modern normal" +vim.opt.expandtab = true vim.opt.shiftwidth = 4 vim.opt.tabstop = 4 vim.opt.softtabstop = 4 --- Auto indent -vim.opt.ai = true - --- Smart indent -vim.opt.si = true - --- Wrap lines -vim.opt.wrap = true - ---[[ -Moving around, tabs, windows and buffers ---]] -- Disable highlight when <leader><cr> is pressed -map('n', '<leader><cr>', ':noh<cr>', silentnoremap) +vim.api.nvim_set_keymap('n', '<leader><cr>', ':noh<cr>', { noremap = true, silent = true }) -- Tab commands -map('n', '<leader>tn', ':tabnext<cr>', silentnoremap) -map('n', '<leader>tc', ':tabnew<cr>', silentnoremap) -map('n', '<leader>tx', ':tabclose<cr>', silentnoremap) - --- Always show tabbar -vim.opt.stal = 1 +vim.api.nvim_set_keymap('n', '<leader>tn', ':tabnext<cr>', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '<leader>tc', ':tabnew<cr>', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '<leader>tx', ':tabclose<cr>', { noremap = true, silent = true }) -- Return to last edit position when opening files (You want this!) vim.cmd [[ au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] ---[[ -Status Line ---]] - --- Always show status line -vim.opt.laststatus = 2 - ---[[ -Mappings ---]] - --- Interact with system clipboard -map('v', '<leader>y', '"+y', noremap) -map('n', '<leader>Y', '"+yg_', noremap) -map('n', '<leader>y', '"+y', noremap) - -map('v', '<leader>p', '"+p', noremap) -map('v', '<leader>P', '"+P', noremap) -map('n', '<leader>p', '"+p', noremap) -map('n', '<leader>P', '"+P', noremap) - ---[[ -Misc ---]] - --- Scribble buffer -map('n', '<leader>q', ':e ~/buffer<cr>', silentnoremap) - --- Toggle paste mode -map('n', '<leader>pp', ':setlocal paste!<cr>', silentnoremap) - --- Send file-title to tmux -vim.opt.titlestring = [[%f %h%m%r%w%{v:progname} (%{tabpagenr()} of %{tabpagenr('$')}})]] -vim.opt.title = true - ---[[ -Debugging ---]] +-- Debugging vim.g.termdebug_popup = 0 vim.g.termdebug_wide = 163 -vim.cmd([[:packadd termdebug]]) +vim.cmd([[:packadd! termdebug]]) + +-- Colorscheme +vim.cmd [[ colorscheme default ]] +vim.opt.background = "light" +vim.opt.termguicolors = true +-- No idea why, preview in fzf does at least work extremely porly without this +vim.cmd [[ let $BAT_THEME = 'gruvbox-light' ]] +-- Show colour column +vim.opt.colorcolumn = '80,120' +vim.api.nvim_set_hl(0, "ColorColumn", { ctermbg = "lightgrey", bg = "#eae7da" }) --- This is to get rid of weird artifacts with text showing up inside buffer. -vim.opt.title = false diff --git a/Common/nvim/lua/helper_functions.lua b/Common/nvim/lua/helper_functions.lua index 05150c0..5889d5b 100755 --- a/Common/nvim/lua/helper_functions.lua +++ b/Common/nvim/lua/helper_functions.lua @@ -1,17 +1,8 @@ --- opts that replicate the nore part of noremap -silentnoremap = { noremap = true, silent = true } -noremap = { noremap = true, silent = false } - --- Just to make the map function "shorter" -function map(kind, lhs, rhs, opts) - vim.api.nvim_set_keymap(kind, lhs, rhs, opts) -end - --- True if Paste Mode is enabled -function HasPaste() - return vim.opt.paste:get() and 'PASTE MODE ' or '' -end -vim.api.nvim_create_user_command('HasPaste', HasPaste, {bang=true, desc='Returns a string with PASTE MODE if paste is on.'}) +-- Convenient sudo saving of file +vim.api.nvim_create_user_command( + 'W', 'w !sudo tee % > /dev/null', + {bang=true, desc='Save file using sudo'} +) -- Toggles wether special characters are visible list_chars_enabled = false @@ -21,7 +12,7 @@ function ToggleListChars() vim.opt.list = list_chars_enabled vim.opt.listchars = list_chars_enabled and list_chars_when_enabled or 'eol:$' end -vim.keymap.set('n', '<leader><tab>', ToggleListChars, silentnoremap) +vim.keymap.set('n', '<leader><tab>', ToggleListChars, { noremap = true, silent = true }) -- Command to join lines in buffer as list function JoinLines(args, quotes) @@ -184,3 +175,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Reminders for system clipboard register +vim.api.nvim_set_keymap('v', '<leader>y', [[:lua vim.api.nvim_echo({{"Use register '+' for system clipboard", "ErrorMsg"}}, false, {})<CR>]], {noremap = true, silent=false}) +vim.api.nvim_set_keymap('n', '<leader>y', [[:lua vim.api.nvim_echo({{"Use register '+' for system clipboard", "ErrorMsg"}}, false, {})<CR>]], {noremap = true, silent=false}) + diff --git a/Common/nvim/lua/lsp-conf.lua b/Common/nvim/lua/lsp-conf.lua index bfcc3dd..0bb0a3e 100644 --- a/Common/nvim/lua/lsp-conf.lua +++ b/Common/nvim/lua/lsp-conf.lua @@ -31,10 +31,10 @@ local sign = function(opts) }) end -sign({name = 'DiagnosticSignError', text = ''}) -sign({name = 'DiagnosticSignWarn', text = ''}) -sign({name = 'DiagnosticSignHint', text = ''}) -sign({name = 'DiagnosticSignInfo', text = ''}) +sign({name = 'DiagnosticSignError', text = '!'}) +sign({name = 'DiagnosticSignWarn', text = '!!'}) +sign({name = 'DiagnosticSignHint', text = '?'}) +sign({name = 'DiagnosticSignInfo', text = 'i'}) vim.diagnostic.config({ virtual_text = false, @@ -61,9 +61,11 @@ vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} vim.opt.shortmess = vim.opt.shortmess + { c = true} vim.api.nvim_set_option('updatetime', 300) -vim.cmd([[ -set signcolumn=yes -]]) +-- Enable signcolumn +vim.opt.signcolumn = 'yes' +-- Remove background in SignColumn, looks odd without this +vim.api.nvim_set_hl(0, "SignColumn", {link = "LineNr"}) + -- autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float) diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua index 7610540..67bd4d1 100755 --- a/Common/nvim/lua/plugins.lua +++ b/Common/nvim/lua/plugins.lua @@ -19,13 +19,6 @@ return require('packer').startup(function(use) -- Git plugins use { - 'lewis6991/gitsigns.nvim', - config = function() - require('gitsigns').setup() - map("n", "<leader>s", ":Gitsigns toggle_current_line_blame<cr>", silentnoremap) - end, - } - use { 'tpope/vim-fugitive', } @@ -56,12 +49,32 @@ return require('packer').startup(function(use) \ 'spinner': ['fg', 'Label'], \ 'header': ['fg', 'Comment'] } ]] - map("n", ";", ":Files<cr>", silentnoremap) - map("n", "<leader>;", ":Rg<cr>", silentnoremap) - map("n", "<leader><leader>;", ":Lines<cr>", silentnoremap) + vim.api.nvim_set_keymap("n", ";", ":Files<cr>", { noremap = true, silent = true }) + vim.api.nvim_set_keymap("n", "<leader>;", ":Rg<cr>", { noremap = true, silent = true }) + vim.api.nvim_set_keymap("n", "<leader><leader>;", ":Lines<cr>", { noremap = true, silent = true }) end, } + -- Lsp things + use { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'neovim/nvim-lspconfig' , + } + + -- Treesitter, quicker highlighting and such + use { + "nvim-treesitter/nvim-treesitter", + config = function() + require'nvim-treesitter.configs'.setup { + ensure_installed = { "c", "cpp", "python", "php", "java", "lua", "vim", "vimdoc", "query", "php", "sql" }, + sync_install = false, + auto_install = true, + --ignore_install = { "javascript" }, + } + end + } + -- vim-dadbob (run sql directly) use { 'tpope/vim-dadbod', @@ -85,15 +98,10 @@ return require('packer').startup(function(use) end, } - -- Lsp things + -- Useful for wide screens use { - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'neovim/nvim-lspconfig' , + 'smithbm2316/centerpad.nvim' } - -- Language-specifics - use 'simrat39/rust-tools.nvim' - --use 'mfussenegger/nvim-jdtls' -- VimWiki stuff use { @@ -163,43 +171,6 @@ return require('packer').startup(function(use) end } - --use 'tpope/vim-surround' - use { - "nvim-treesitter/nvim-treesitter", - config = function() - require'nvim-treesitter.configs'.setup { - ensure_installed = { "c", "cpp", "python", "php", "java", "lua", "vim", "vimdoc", "query", "php", "sql" }, - sync_install = false, - auto_install = true, - --ignore_install = { "javascript" }, - } - end - } - use 'evanleck/vim-svelte' - use 'pangloss/vim-javascript' - use 'ledger/vim-ledger' - - -- use { 'junegunn/goyo.vim' } - -- use { 'smithbm2316/centerpad.nvim' } - - -- Color picker - use { - "ziontee113/color-picker.nvim", - config = function() - require("color-picker") - end, - } - -- TagBar - -- use { - -- 'preservim/tagbar', - -- config = function() - -- map("n", "<F2>", ":TagbarToggle<cr>", silentnoremap) - -- end, - -- } - -- Vim tmux navigator - -- use 'christoomey/vim-tmux-navigator' - - -- Automatically set up your configuration after cloning packer.nvim -- Put this at the end after all plugins if packer_bootstrap then |