From bcb84e54eb49f227c471ae8bd36508ad224f2e0c Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 14 May 2024 11:37:21 +0200 Subject: [PATCH] touching the nvim again --- nvim/lua/config/autocmd.lua | 10 ++++++ nvim/lua/config/autotag.lua | 19 +++++++++++ nvim/lua/config/cmp.lua | 2 +- nvim/lua/config/colorscheme.lua | 4 ++- nvim/lua/config/filetypes.lua | 14 ++++++-- nvim/lua/config/keymaps.lua | 12 ++++--- nvim/lua/config/lsp.lua | 2 ++ nvim/lua/config/oil.lua | 25 ++++++++++++++ nvim/lua/config/options.lua | 58 ++++++++++++++++++++++----------- nvim/lua/plugins/core.lua | 19 +---------- nvim/lua/plugins/lsp.lua | 2 +- 11 files changed, 120 insertions(+), 47 deletions(-) create mode 100644 nvim/lua/config/autotag.lua diff --git a/nvim/lua/config/autocmd.lua b/nvim/lua/config/autocmd.lua index 01f049c..9e0ef74 100644 --- a/nvim/lua/config/autocmd.lua +++ b/nvim/lua/config/autocmd.lua @@ -1,5 +1,15 @@ local autocmd = vim.api.nvim_create_autocmd +-- Highlight on yank +autocmd('TextYankPost', { + group = vim.api.nvim_create_augroup('highlight_yank', {}), + desc = 'Hightlight selection on yank', + pattern = '*', + callback = function() + vim.highlight.on_yank { higroup = 'IncSearch', timeout = 400 } + end, +}) + -- Remove all trailing whitespaces on save autocmd('BufWritePre', { command = [[:exe 'norm m`' | %s/\s\+$//eg | norm ``]] diff --git a/nvim/lua/config/autotag.lua b/nvim/lua/config/autotag.lua new file mode 100644 index 0000000..fb48f7f --- /dev/null +++ b/nvim/lua/config/autotag.lua @@ -0,0 +1,19 @@ +return { + -- Filetypes to enable autotag for + filetypes = { + 'html', + 'javascript', + 'typescript', + 'javascriptreact', + 'typescriptreact', + 'svelte', + 'vue', + 'tsx', + 'jsx', + 'rescript', + 'xml', + 'php', + 'blade', + 'markdown', + } +} diff --git a/nvim/lua/config/cmp.lua b/nvim/lua/config/cmp.lua index 791e465..d7f0375 100644 --- a/nvim/lua/config/cmp.lua +++ b/nvim/lua/config/cmp.lua @@ -7,7 +7,7 @@ return function() local selectNext = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }) local windowstyle = { - border = "none", + border = vim.g.float_border or 'none', winhighlight = 'Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None', } diff --git a/nvim/lua/config/colorscheme.lua b/nvim/lua/config/colorscheme.lua index 6846540..283afa7 100644 --- a/nvim/lua/config/colorscheme.lua +++ b/nvim/lua/config/colorscheme.lua @@ -25,7 +25,7 @@ return { -- Floating windows NormalFloat = { fg = colors.text, bg = colors.mantle }, FloatTitle = { fg = colors.base, bg = colors.blue }, - FloatBorder = { fg = colors.blue, bg = colors.mantle }, + FloatBorder = { fg = colors.surface1, bg = colors.mantle }, -- Window separator WinSeparator = { fg = colors.surface0 }, @@ -40,6 +40,8 @@ return { -- indent lines IblScope = { fg = colors.overlay1 }, + IncSearch = { bg = colors.yellow }, + -- LSP -- LspReferenceText = { bg = colors.surface0 }, -- LspReferenceRead = { link = "LspReferenceText" }, diff --git a/nvim/lua/config/filetypes.lua b/nvim/lua/config/filetypes.lua index f365e0f..2fa17ff 100644 --- a/nvim/lua/config/filetypes.lua +++ b/nvim/lua/config/filetypes.lua @@ -12,10 +12,20 @@ vim.filetype.add({ }, }) --- Fix autocomment plugins to use line comments for php. +-- PHP autocmd('Filetype', { pattern = 'php', - command = 'setlocal commentstring=//\\%s' + callback = function() + -- Fix autocomment plugins to use line comments + vim.cmd('setlocal commentstring=//\\%s') + + -- Goto file for blade files in laravel projects + vim.cmd([[ + set path=.,resources/views + set suffixesadd=.blade.php + set includeexpr=substitute(v:fname,'\\.','/','g') + ]]) + end }) diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index 41bfe1e..b0de05d 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -8,6 +8,8 @@ return { -- global = { + { "n", "W", "lua vim.opt.list = not vim.opt.list._value", { silent = true, desc = "Toggle show whitespace" } }, + -- -- Navigation -- @@ -19,10 +21,10 @@ return { { "n", "", "zz", { silent = true, desc = "jump half a page down" } }, -- Split windows - { "n", "", "h", { silent = true, desc = "Goto left split" } }, - { "n", "", "j", { silent = true, desc = "Goto down split" } }, - { "n", "", "k", { silent = true, desc = "Goto up split" } }, - { "n", "", "l", { silent = true, desc = "Goto right split" } }, + { "n", "", "h", { silent = true, desc = "Focus left split" } }, + { "n", "", "j", { silent = true, desc = "Focus down split" } }, + { "n", "", "k", { silent = true, desc = "Focus up split" } }, + { "n", "", "l", { silent = true, desc = "Focus right split" } }, -- Make jump to next search item stay in the center of screen. { "n", "n", "nzzzv", { silent = true, desc = "jump to next search match" } }, @@ -44,7 +46,7 @@ return { { { "n", "v" }, "p", [["+p]], { desc = "Paste from system clipboard register" } }, -- File operations - { "n", "Fe", "Ex", { silent = true, desc = "Open Netrw" } }, + -- { "n", "Fe", "Ex", { silent = true, desc = "Open Netrw" } }, { "n", "Fc", ":CreateFile ", { silent = true, desc = "Create new file" } }, { "n", "Fx", "!chmod +x %", { silent = true, desc = "Set execute flag on current file" } }, diff --git a/nvim/lua/config/lsp.lua b/nvim/lua/config/lsp.lua index 8c4d0bd..1f7ded7 100644 --- a/nvim/lua/config/lsp.lua +++ b/nvim/lua/config/lsp.lua @@ -1,3 +1,5 @@ +vim.g.lsp_zero_ui_float_border = vim.g.float_border or 'none' + return { servers = { -- PHP diff --git a/nvim/lua/config/oil.lua b/nvim/lua/config/oil.lua index 1022a9a..ec719d1 100644 --- a/nvim/lua/config/oil.lua +++ b/nvim/lua/config/oil.lua @@ -1,4 +1,23 @@ return { + default_file_explorer = true, + prompt_save_on_select_new_entry = false, + keymaps = { + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = "actions.select_vsplit", + [""] = "actions.preview", + [""] = "actions.close", + [""] = "actions.refresh", + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = "actions.tcd", + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["g."] = "actions.toggle_hidden", + ["g\\"] = "actions.toggle_trash", + }, + use_default_keymaps = false, float = { -- Padding around the floating window padding = 2, @@ -9,4 +28,10 @@ return { winblend = 0, }, }, + ssh = { + border = "single", + }, + keymaps_help = { + border = "single", + } } diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua index 5cebe32..339f3b6 100644 --- a/nvim/lua/config/options.lua +++ b/nvim/lua/config/options.lua @@ -1,13 +1,30 @@ local set = vim.opt local icons = require('config.icons') +-- +-- Variables +-- + + +-- Custom +vim.g.float_border = 'single' + + -- -- General Settings -- set.termguicolors = true + +-- Decrease update time set.updatetime = 50 -set.showmode = false -- disable mode in the command line, because i use lualine + +-- Decrease mapped sequence wait time +-- Displays which-key popup sooner +set.timeoutlen = 50 + +-- disable mode in the command line, because i use lualine +set.showmode = false -- @@ -20,6 +37,16 @@ set.laststatus = 3 set.splitkeep = "screen" set.scrolloff = 20 +-- Configure how new splits should be opened +set.splitright = true +set.splitbelow = true + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +set.list = false +set.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + set.fillchars = { foldopen = icons.fold.open, foldclose = icons.fold.close, @@ -36,6 +63,7 @@ set.mousemoveevent = true -- search set.hlsearch = false set.incsearch = true +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term set.ignorecase = true set.smartcase = true @@ -69,28 +97,20 @@ set.foldcolumn = "auto" -- Diagnostics -- - - -vim.fn.sign_define('DiagnosticSignError', { text = icons.diagnostics.error, texthl = 'DiagnosticSignError' }) -vim.fn.sign_define('DiagnosticSignWarn', { text = icons.diagnostics.warn, texthl = 'DiagnosticSignWarn' }) -vim.fn.sign_define('DiagnosticSignInfo', { text = icons.diagnostics.info, texthl = 'DiagnosticSignInfo' }) -vim.fn.sign_define('DiagnosticSignHint', { text = icons.diagnostics.hint, texthl = 'DiagnosticSignHint' }) - vim.diagnostic.config({ virtual_text = false, severity_sort = true, underline = false, - float = { - -- border = 'single', + signs = { + text = { + [vim.diagnostic.severity.ERROR] = icons.diagnostics.error, + [vim.diagnostic.severity.WARN] = icons.diagnostics.warn, + [vim.diagnostic.severity.INFO] = icons.diagnostics.info, + [vim.diagnostic.severity.HINT] = icons.diagnostics.hint + }, }, + float = { + border = vim.g.float_border, + } }) --- Highlight on yank -vim.api.nvim_create_autocmd('TextYankPost', { - group = vim.api.nvim_create_augroup('highlight_yank', {}), - desc = 'Hightlight selection on yank', - pattern = '*', - callback = function() - vim.highlight.on_yank { higroup = 'IncSearch', timeout = 400 } - end, -}) diff --git a/nvim/lua/plugins/core.lua b/nvim/lua/plugins/core.lua index 3bdec80..bcc94ec 100644 --- a/nvim/lua/plugins/core.lua +++ b/nvim/lua/plugins/core.lua @@ -64,24 +64,7 @@ return { dependencies = { 'nvim-treesitter/nvim-treesitter' }, - opts = { - filetypes = { - 'html', - 'javascript', - 'typescript', - 'javascriptreact', - 'typescriptreact', - 'svelte', - 'vue', - 'tsx', - 'jsx', - 'rescript', - 'xml', - 'php', - 'blade', - 'markdown', - } - } + opts = require('config.autotag') }, { "lukas-reineke/indent-blankline.nvim", diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 6ca8ca4..42cf47b 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -57,7 +57,7 @@ return { end server_opt = vim.tbl_deep_extend("force", {on_attach = on_attach}, server_opt or {}) - + lsp_config[name].setup(server_opt) end end,