refactor nvim

This commit is contained in:
AntoXa PRO 2023-10-03 23:01:09 +03:00
parent da47cf5192
commit ee5e687a2d
5 changed files with 25 additions and 25 deletions

View File

@ -25,6 +25,7 @@ vim.o.clipboard = 'unnamedplus'
-- View. -- View.
vim.g.mapleader = ' ' vim.g.mapleader = ' '
vim.g.netrw_liststyle = 3 vim.g.netrw_liststyle = 3
vim.o.termguicolors = true
vim.o.list = true vim.o.list = true
vim.opt.listchars:append 'space:⋅' vim.opt.listchars:append 'space:⋅'
@ -44,7 +45,7 @@ vim.keymap.set('n', '<C-d>', '<C-d>zz')
vim.keymap.set('n', '<C-u>', '<C-u>zz') vim.keymap.set('n', '<C-u>', '<C-u>zz')
-- Diagnostic keymaps. -- 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_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)

View File

@ -47,6 +47,10 @@ local on_attach = function(_, bufnr)
vim.keymap.set('n', 'K', vim.lsp.buf.hover) vim.keymap.set('n', 'K', vim.lsp.buf.hover)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help) vim.keymap.set('n', '<C-k>', 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 end
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers

View File

@ -1,5 +1,10 @@
local status = pcall(require, 'nightfox') local status = pcall(require, 'nightfox')
if status then 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 end

View File

@ -9,13 +9,5 @@ local formatting = null_ls.builtins.formatting
null_ls.setup { null_ls.setup {
sources = { sources = {
formatting.prettier.with({ extra_args = { "--config", prettier_config } }) 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
} }

View File

@ -14,18 +14,16 @@ telescope.setup {
} }
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>sf', builtin.find_files)
vim.keymap.set('n', '<leader>sw', builtin.grep_string)
vim.keymap.set('n', '<leader>sg', builtin.live_grep)
vim.keymap.set('n', '<leader>?', builtin.oldfiles)
vim.keymap.set('n', '<leader>/', function() vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc. builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10, winblend = 10,
previewer = false, previewer = false,
}) })
end, { desc = '[/] Fuzzily search in current buffer' }) end)
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })