From 898bde9931a6fdebcc3daa6b87ee355b981f8919 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Sun, 17 Sep 2023 16:09:25 +0930 Subject: [PATCH] Add dadbod and noice to nvim --- .config/nvim/lua/config/dadbod.lua | 3 + .../nvim/lua/config/general/colorscheme.lua | 3 - .config/nvim/lua/config/general/init.lua | 3 - .config/nvim/lua/config/general/remaps.lua | 3 - .config/nvim/lua/config/lsp.lua | 14 ++--- .config/nvim/lua/config/noice.lua | 18 ++++++ .config/nvim/lua/config/null-ls.lua | 32 ---------- .config/nvim/lua/config/telescope.lua | 60 ++++++++++--------- .config/nvim/lua/config/tmux.lua | 4 -- .config/nvim/lua/config/treesitter.lua | 1 - .config/nvim/lua/packer-plugins.lua | 34 ++++++++++- 11 files changed, 90 insertions(+), 85 deletions(-) create mode 100644 .config/nvim/lua/config/dadbod.lua delete mode 100644 .config/nvim/lua/config/general/colorscheme.lua create mode 100644 .config/nvim/lua/config/noice.lua delete mode 100644 .config/nvim/lua/config/null-ls.lua diff --git a/.config/nvim/lua/config/dadbod.lua b/.config/nvim/lua/config/dadbod.lua new file mode 100644 index 0000000..5843a7b --- /dev/null +++ b/.config/nvim/lua/config/dadbod.lua @@ -0,0 +1,3 @@ +vim.cmd[[ let g:db_ui_winwidth = 30 ]] + +vim.keymap.set('n', 'db', ':DBUIToggle', { noremap = true }) diff --git a/.config/nvim/lua/config/general/colorscheme.lua b/.config/nvim/lua/config/general/colorscheme.lua deleted file mode 100644 index 2f05510..0000000 --- a/.config/nvim/lua/config/general/colorscheme.lua +++ /dev/null @@ -1,3 +0,0 @@ - -vim.cmd [[colorscheme gruvbox]] - diff --git a/.config/nvim/lua/config/general/init.lua b/.config/nvim/lua/config/general/init.lua index 5e5adc5..7a87ec3 100644 --- a/.config/nvim/lua/config/general/init.lua +++ b/.config/nvim/lua/config/general/init.lua @@ -1,6 +1,3 @@ - require('config.general.options') require('config.general.remaps') require('config.general.autocmd') - -require('config.general.colorscheme') diff --git a/.config/nvim/lua/config/general/remaps.lua b/.config/nvim/lua/config/general/remaps.lua index b5b6f10..270fd6f 100644 --- a/.config/nvim/lua/config/general/remaps.lua +++ b/.config/nvim/lua/config/general/remaps.lua @@ -37,9 +37,6 @@ vim.api.nvim_set_keymap('n', options ) --- Replace all is aliased to S. -vim.api.nvim_set_keymap('n', '', '%s//g', options) - -- Navigating with guides vim.api.nvim_set_keymap('n', '', diff --git a/.config/nvim/lua/config/lsp.lua b/.config/nvim/lua/config/lsp.lua index 0a732a6..89997ad 100644 --- a/.config/nvim/lua/config/lsp.lua +++ b/.config/nvim/lua/config/lsp.lua @@ -3,9 +3,13 @@ lsp.preset('recommended') local luasnip = require("luasnip") lsp.ensure_installed({ + 'lua_ls', 'tsserver', 'eslint', - 'gopls' + 'gopls', + 'intelephense', + 'jsonls', + 'volar', }) local has_words_before = function() @@ -37,7 +41,7 @@ local cmp_mappings = lsp.defaults.cmp_mappings({ i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, c = function(fallback) if cmp.visible() then - cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } else fallback() end @@ -89,6 +93,7 @@ lsp.on_attach(function(client, bufnr) -- Key mappings vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) vim.keymap.set("n", "[e", function () vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR}) end, opts) @@ -98,12 +103,7 @@ lsp.on_attach(function(client, bufnr) vim.keymap.set("n", "ka", vim.lsp.buf.code_action, opts) vim.keymap.set("n", "of", vim.diagnostic.open_float, opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - -- vim.keymap.set("n", "gr", function() vim.lsp.buf.references({ includeDeclaration = false }) end, opts) vim.keymap.set("n", "gh", vim.lsp.buf.signature_help, opts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) - vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts) end) lsp.setup() diff --git a/.config/nvim/lua/config/noice.lua b/.config/nvim/lua/config/noice.lua new file mode 100644 index 0000000..7de2a22 --- /dev/null +++ b/.config/nvim/lua/config/noice.lua @@ -0,0 +1,18 @@ +require("noice").setup({ + 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 = false, -- 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 + }, +}) diff --git a/.config/nvim/lua/config/null-ls.lua b/.config/nvim/lua/config/null-ls.lua deleted file mode 100644 index 218d276..0000000 --- a/.config/nvim/lua/config/null-ls.lua +++ /dev/null @@ -1,32 +0,0 @@ -local null_ls = require("null-ls") - -local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false }) -local event = "BufWritePre" -- or "BufWritePost" -local async = event == "BufWritePost" - -null_ls.setup({ - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.keymap.set("n", "ff", function() - vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() }) - end, { buffer = bufnr, desc = "[lsp] format" }) - - -- format on save - vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group }) - vim.api.nvim_create_autocmd(event, { - buffer = bufnr, - group = group, - callback = function() - vim.lsp.buf.format({ bufnr = bufnr, async = async }) - end, - desc = "[lsp] format on save", - }) - end - - if client.supports_method("textDocument/rangeFormatting") then - vim.keymap.set("x", "f", function() - vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() }) - end, { buffer = bufnr, desc = "[lsp] format" }) - end - end, -}) diff --git a/.config/nvim/lua/config/telescope.lua b/.config/nvim/lua/config/telescope.lua index bf6add5..f60177d 100644 --- a/.config/nvim/lua/config/telescope.lua +++ b/.config/nvim/lua/config/telescope.lua @@ -1,24 +1,26 @@ -local pickers = require("telescope.pickers") -local finders = require("telescope.finders") -local previewers = require("telescope.previewers") -local action_state = require("telescope.actions.state") -local conf = require("telescope.config").values -local actions = require("telescope.actions") +local pickers = require('telescope.pickers') +local finders = require('telescope.finders') +local previewers = require('telescope.previewers') +local action_state = require('telescope.actions.state') +local conf = require('telescope.config').values +local builtin = require('telescope.builtin') +local sorters = require('telescope.sorters') +local actions = require('telescope.actions') -require("telescope").setup({ +require('telescope').setup({ defaults = { - file_sorter = require("telescope.sorters").get_fzy_sorter, - prompt_prefix = " >", + file_sorter = sorters.get_fzy_sorter, + prompt_prefix = ' >', color_devicons = true, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + file_previewer = previewers.vim_buffer_cat.new, + grep_previewer = previewers.vim_buffer_vimgrep.new, + qflist_previewer = previewers.vim_buffer_qflist.new, mappings = { i = { - [""] = false, - [""] = actions.send_to_qflist, + [''] = false, + [''] = actions.send_to_qflist, }, }, }, @@ -27,7 +29,7 @@ require("telescope").setup({ local M = {} function git_branches () - require("telescope.builtin").git_branches({ + builtin.git_branches({ attach_mappings = function(_, map) map("i", "", actions.git_delete_branch) map("n", "", actions.git_delete_branch) @@ -38,37 +40,37 @@ end function files () local ran, errorMessage = pcall(function() - require('telescope.builtin').git_files({ show_untracked = true }) + builtin.git_files({ show_untracked = true }) end) if not ran then - require('telescope.builtin').find_files() + builtin.find_files() end end local options = { noremap = true } -vim.keymap.set('n', '', require('telescope.builtin').live_grep, options) +vim.keymap.set('n', '', builtin.live_grep, options) vim.keymap.set('n', '', files, options) -vim.keymap.set('n', '', function() - require('telescope.builtin').find_files() -end, options) - vim.keymap.set('n', 'df', function() - require("telescope.builtin").find_files({ + builtin.find_files({ prompt_title = "< VimRC >", cwd = vim.fn.expand('~/.config/nvim'), hidden = true, }) end, options) -vim.keymap.set('n', 'fb', require('telescope.builtin').buffers, options) -vim.keymap.set('n', 'fo', require('telescope.builtin').oldfiles, options) -vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, options) +vim.keymap.set('n', 'fb', builtin.buffers, options) +vim.keymap.set('n', 'fo', builtin.oldfiles, options) + +vim.keymap.set('n', 'gr', builtin.lsp_references, options) +vim.keymap.set("n", 'gd', builtin.lsp_definitions, options) +vim.keymap.set("n", 'gi', builtin.lsp_implementations, options) +vim.keymap.set("n", 'gT', builtin.lsp_type_definitions, options) -vim.keymap.set('n', 'm', require('telescope.builtin').marks, options) -vim.keymap.set('n', 'ch', require('telescope.builtin').command_history, options) +vim.keymap.set('n', 'm', builtin.marks, options) +vim.keymap.set('n', 'ch', builtin.command_history, options) vim.keymap.set('n', 'gb', git_branches, options) -vim.keymap.set('n', 'gs', require('telescope.builtin').git_status, options) +vim.keymap.set('n', 'gs', builtin.git_status, options) diff --git a/.config/nvim/lua/config/tmux.lua b/.config/nvim/lua/config/tmux.lua index da0ec7e..59f62ad 100644 --- a/.config/nvim/lua/config/tmux.lua +++ b/.config/nvim/lua/config/tmux.lua @@ -1,9 +1,5 @@ require("tmux").setup({ - -- overwrite default configuration - -- here, e.g. to enable default bindings copy_sync = { - -- enables copy sync and overwrites all register actions to - -- sync registers *, +, unnamed, and 0 till 9 from tmux in advance enable = true, }, navigation = { diff --git a/.config/nvim/lua/config/treesitter.lua b/.config/nvim/lua/config/treesitter.lua index 2ebecc2..0d4a056 100644 --- a/.config/nvim/lua/config/treesitter.lua +++ b/.config/nvim/lua/config/treesitter.lua @@ -1,5 +1,4 @@ require('nvim-treesitter.configs').setup { - -- A list of parser names, or "all" ensure_installed = { 'go', 'dart', 'php', 'javascript' }, -- Install parsers synchronously (only applied to `ensure_installed`) diff --git a/.config/nvim/lua/packer-plugins.lua b/.config/nvim/lua/packer-plugins.lua index 089fcc3..9bd2074 100644 --- a/.config/nvim/lua/packer-plugins.lua +++ b/.config/nvim/lua/packer-plugins.lua @@ -3,7 +3,13 @@ return require('packer').startup(function() use { 'wbthomason/packer.nvim' } -- colorschemes - use { 'gruvbox-community/gruvbox' } + use { + 'gruvbox-community/gruvbox', + config = function () + vim.cmd [[colorscheme gruvbox]] + end + + } use { 'bluz71/vim-moonfly-colors' } use { @@ -165,13 +171,35 @@ return require('packer').startup(function() use { 'MunifTanjim/prettier.nvim', requires = { - 'jose-elias-alvarez/null-ls.nvim', + -- 'jose-elias-alvarez/null-ls.nvim', 'neovim/nvim-lspconfig', }, config = function() - require('config.null-ls') + -- require('config.null-ls') require('config.prettier') end } + + use { + 'folke/noice.nvim', + requires = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + config = function () + require('config.noice') + end + } + + use { + 'kristijanhusak/vim-dadbod-ui', + requires = { + 'tpope/vim-dadbod', + }, + config = function() + require('config.dadbod') + end + } end)