From ee5e687a2d8076394bafd2bd0d276109165d5460 Mon Sep 17 00:00:00 2001 From: AntoXa PRO Date: Tue, 3 Oct 2023 23:01:09 +0300 Subject: [PATCH] refactor nvim --- nvim/.config/nvim/lua/axp/base.lua | 9 +++++---- nvim/.config/nvim/lua/axp/plugins/lsp.lua | 4 ++++ .../.config/nvim/lua/axp/plugins/nightfox.lua | 7 ++++++- .../nvim/lua/axp/plugins/null-ls/init.lua | 10 +--------- .../nvim/lua/axp/plugins/telescope.lua | 20 +++++++++---------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/nvim/.config/nvim/lua/axp/base.lua b/nvim/.config/nvim/lua/axp/base.lua index e1e6ce4..e493252 100644 --- a/nvim/.config/nvim/lua/axp/base.lua +++ b/nvim/.config/nvim/lua/axp/base.lua @@ -25,6 +25,7 @@ vim.o.clipboard = 'unnamedplus' -- View. vim.g.mapleader = ' ' vim.g.netrw_liststyle = 3 +vim.o.termguicolors = true vim.o.list = true vim.opt.listchars:append 'space:⋅' @@ -44,7 +45,7 @@ vim.keymap.set('n', '', 'zz') vim.keymap.set('n', '', 'zz') -- Diagnostic keymaps. -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) +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', 'q', vim.diagnostic.setloclist) diff --git a/nvim/.config/nvim/lua/axp/plugins/lsp.lua b/nvim/.config/nvim/lua/axp/plugins/lsp.lua index b2da364..818f032 100644 --- a/nvim/.config/nvim/lua/axp/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/axp/plugins/lsp.lua @@ -47,6 +47,10 @@ local on_attach = function(_, bufnr) vim.keymap.set('n', 'K', vim.lsp.buf.hover) vim.keymap.set('n', '', vim.lsp.buf.signature_help) + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities, so broadcast that to servers diff --git a/nvim/.config/nvim/lua/axp/plugins/nightfox.lua b/nvim/.config/nvim/lua/axp/plugins/nightfox.lua index 82bf206..2745224 100644 --- a/nvim/.config/nvim/lua/axp/plugins/nightfox.lua +++ b/nvim/.config/nvim/lua/axp/plugins/nightfox.lua @@ -1,5 +1,10 @@ local status = pcall(require, 'nightfox') if status then - vim.cmd [[colorscheme terafox]] + -- Apply theme. + vim.cmd.colorscheme('terafox') + + -- Transparency. + vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) end diff --git a/nvim/.config/nvim/lua/axp/plugins/null-ls/init.lua b/nvim/.config/nvim/lua/axp/plugins/null-ls/init.lua index eb8ccea..b409aa3 100644 --- a/nvim/.config/nvim/lua/axp/plugins/null-ls/init.lua +++ b/nvim/.config/nvim/lua/axp/plugins/null-ls/init.lua @@ -9,13 +9,5 @@ local formatting = null_ls.builtins.formatting null_ls.setup { sources = { formatting.prettier.with({ extra_args = { "--config", prettier_config } }) - }, - on_attach = function (client, bufnr) - if client.supports_method('textDocument/formatting') then - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) - end - end + } } diff --git a/nvim/.config/nvim/lua/axp/plugins/telescope.lua b/nvim/.config/nvim/lua/axp/plugins/telescope.lua index e82ddb3..00ca2e1 100644 --- a/nvim/.config/nvim/lua/axp/plugins/telescope.lua +++ b/nvim/.config/nvim/lua/axp/plugins/telescope.lua @@ -14,18 +14,16 @@ telescope.setup { } -- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +local builtin = require('telescope.builtin') + +vim.keymap.set('n', 'sf', builtin.find_files) +vim.keymap.set('n', 'sw', builtin.grep_string) +vim.keymap.set('n', 'sg', builtin.live_grep) + +vim.keymap.set('n', '?', builtin.oldfiles) vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +end)