Skip to content

Commit 800d6f7

Browse files
micaiah-effiongmayronH
authored andcommitted
feat: added contexts for code action - source fix-all errors (nvim-lua#599)
* feat: added contexts for code action - source fix-all errors * fix: resolve stylua checks * fix: resolve stylua checks
1 parent 0c69478 commit 800d6f7

File tree

2 files changed

+3
-216
lines changed

2 files changed

+3
-216
lines changed

init.lua

Lines changed: 0 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -48,222 +48,7 @@ vim.g.maplocalleader = ' '
4848
require 'lazy-bootstrap'
4949

5050
-- [[ Configure plugins ]]
51-
<<<<<<< HEAD
5251
require 'lazy-plugins'
53-
=======
54-
-- NOTE: Here is where you install your plugins.
55-
-- You can configure plugins using the `config` key.
56-
--
57-
-- You can also configure plugins after the setup call,
58-
-- as they will be available in your neovim runtime.
59-
require('lazy').setup({
60-
-- NOTE: First, some plugins that don't require any configuration
61-
62-
-- Git related plugins
63-
'tpope/vim-fugitive',
64-
'tpope/vim-rhubarb',
65-
66-
-- Detect tabstop and shiftwidth automatically
67-
'tpope/vim-sleuth',
68-
69-
-- NOTE: This is where your plugins related to LSP can be installed.
70-
-- The configuration is done below. Search for lspconfig to find it below.
71-
{
72-
-- LSP Configuration & Plugins
73-
'neovim/nvim-lspconfig',
74-
dependencies = {
75-
-- Automatically install LSPs to stdpath for neovim
76-
{ 'williamboman/mason.nvim', config = true },
77-
'williamboman/mason-lspconfig.nvim',
78-
79-
-- Useful status updates for LSP
80-
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
81-
{ 'j-hui/fidget.nvim', opts = {} },
82-
83-
-- Additional lua configuration, makes nvim stuff amazing!
84-
'folke/neodev.nvim',
85-
},
86-
},
87-
88-
{
89-
-- Autocompletion
90-
'hrsh7th/nvim-cmp',
91-
dependencies = {
92-
-- Snippet Engine & its associated nvim-cmp source
93-
'L3MON4D3/LuaSnip',
94-
'saadparwaiz1/cmp_luasnip',
95-
96-
-- Adds LSP completion capabilities
97-
'hrsh7th/cmp-nvim-lsp',
98-
'hrsh7th/cmp-path',
99-
100-
-- Adds a number of user-friendly snippets
101-
'rafamadriz/friendly-snippets',
102-
},
103-
},
104-
105-
-- Useful plugin to show you pending keybinds.
106-
{ 'folke/which-key.nvim', opts = {} },
107-
{
108-
-- Adds git related signs to the gutter, as well as utilities for managing changes
109-
'lewis6991/gitsigns.nvim',
110-
opts = {
111-
-- See `:help gitsigns.txt`
112-
signs = {
113-
add = { text = '+' },
114-
change = { text = '~' },
115-
delete = { text = '_' },
116-
topdelete = { text = '' },
117-
changedelete = { text = '~' },
118-
},
119-
on_attach = function(bufnr)
120-
local gs = package.loaded.gitsigns
121-
122-
local function map(mode, l, r, opts)
123-
opts = opts or {}
124-
opts.buffer = bufnr
125-
vim.keymap.set(mode, l, r, opts)
126-
end
127-
128-
-- Navigation
129-
map({ 'n', 'v' }, ']c', function()
130-
if vim.wo.diff then
131-
return ']c'
132-
end
133-
vim.schedule(function()
134-
gs.next_hunk()
135-
end)
136-
return '<Ignore>'
137-
end, { expr = true, desc = 'Jump to next hunk' })
138-
139-
map({ 'n', 'v' }, '[c', function()
140-
if vim.wo.diff then
141-
return '[c'
142-
end
143-
vim.schedule(function()
144-
gs.prev_hunk()
145-
end)
146-
return '<Ignore>'
147-
end, { expr = true, desc = 'Jump to previous hunk' })
148-
149-
-- Actions
150-
-- visual mode
151-
map('v', '<leader>hs', function()
152-
gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
153-
end, { desc = 'stage git hunk' })
154-
map('v', '<leader>hr', function()
155-
gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
156-
end, { desc = 'reset git hunk' })
157-
-- normal mode
158-
map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
159-
map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
160-
map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
161-
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
162-
map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
163-
map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
164-
map('n', '<leader>hb', function()
165-
gs.blame_line { full = false }
166-
end, { desc = 'git blame line' })
167-
map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
168-
map('n', '<leader>hD', function()
169-
gs.diffthis '~'
170-
end, { desc = 'git diff against last commit' })
171-
172-
-- Toggles
173-
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
174-
map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
175-
176-
-- Text object
177-
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
178-
end,
179-
},
180-
},
181-
182-
{
183-
-- Theme inspired by Atom
184-
'navarasu/onedark.nvim',
185-
priority = 1000,
186-
lazy = false,
187-
config = function()
188-
require('onedark').setup {
189-
-- Set a style preset. 'dark' is default.
190-
style = 'dark', -- dark, darker, cool, deep, warm, warmer, light
191-
}
192-
require('onedark').load()
193-
end,
194-
},
195-
196-
{
197-
-- Set lualine as statusline
198-
'nvim-lualine/lualine.nvim',
199-
-- See `:help lualine.txt`
200-
opts = {
201-
options = {
202-
icons_enabled = false,
203-
theme = 'auto',
204-
component_separators = '|',
205-
section_separators = '',
206-
},
207-
},
208-
},
209-
210-
{
211-
-- Add indentation guides even on blank lines
212-
'lukas-reineke/indent-blankline.nvim',
213-
-- Enable `lukas-reineke/indent-blankline.nvim`
214-
-- See `:help ibl`
215-
main = 'ibl',
216-
opts = {},
217-
},
218-
219-
-- "gc" to comment visual regions/lines
220-
{ 'numToStr/Comment.nvim', opts = {} },
221-
222-
-- Fuzzy Finder (files, lsp, etc)
223-
{
224-
'nvim-telescope/telescope.nvim',
225-
branch = '0.1.x',
226-
dependencies = {
227-
'nvim-lua/plenary.nvim',
228-
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
229-
-- Only load if `make` is available. Make sure you have the system
230-
-- requirements installed.
231-
{
232-
'nvim-telescope/telescope-fzf-native.nvim',
233-
-- NOTE: If you are having trouble with this installation,
234-
-- refer to the README for telescope-fzf-native for more instructions.
235-
build = 'make',
236-
cond = function()
237-
return vim.fn.executable 'make' == 1
238-
end,
239-
},
240-
},
241-
},
242-
243-
{
244-
-- Highlight, edit, and navigate code
245-
'nvim-treesitter/nvim-treesitter',
246-
dependencies = {
247-
'nvim-treesitter/nvim-treesitter-textobjects',
248-
},
249-
build = ':TSUpdate',
250-
},
251-
252-
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
253-
-- These are some example plugins that I've included in the kickstart repository.
254-
-- Uncomment any of the lines below to enable them.
255-
-- require 'kickstart.plugins.autoformat',
256-
-- require 'kickstart.plugins.debug',
257-
258-
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
259-
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
260-
-- up-to-date with whatever is in the kickstart repo.
261-
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
262-
--
263-
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
264-
-- { import = 'custom.plugins' },
265-
}, {})
266-
>>>>>>> b115814 (Add Onedark Style (#590))
26752

26853
-- [[ Setting options ]]
26954
require 'options'

lua/lsp-setup.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ local on_attach = function(_, bufnr)
1616
end
1717

1818
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
19-
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
19+
nmap('<leader>ca', function()
20+
vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } }
21+
end, '[C]ode [A]ction')
2022

2123
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
2224
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')

0 commit comments

Comments
 (0)