update 20032023
This commit is contained in:
parent
4316ac84df
commit
a69141cce0
255
init.lua
255
init.lua
|
@ -34,9 +34,7 @@ I hope you enjoy your Neovim journey,
|
||||||
- TJ
|
- TJ
|
||||||
|
|
||||||
P.S. You can delete this when you're done too. It's your config now :)
|
P.S. You can delete this when you're done too. It's your config now :)
|
||||||
--]]
|
--]] -- Set <space> as the leader key
|
||||||
|
|
||||||
-- Set <space> as the leader key
|
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
|
@ -48,12 +46,9 @@ vim.g.maplocalleader = ' '
|
||||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
vim.fn.system {
|
vim.fn.system {
|
||||||
'git',
|
'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git',
|
||||||
'clone',
|
|
||||||
'--filter=blob:none',
|
|
||||||
'https://github.com/folke/lazy.nvim.git',
|
|
||||||
'--branch=stable', -- latest stable release
|
'--branch=stable', -- latest stable release
|
||||||
lazypath,
|
lazypath
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
@ -67,60 +62,44 @@ require('lazy').setup({
|
||||||
-- NOTE: First, some plugins that don't require any configuration
|
-- NOTE: First, some plugins that don't require any configuration
|
||||||
|
|
||||||
-- Git related plugins
|
-- Git related plugins
|
||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive', 'tpope/vim-rhubarb', -- Detect tabstop and shiftwidth automatically
|
||||||
'tpope/vim-rhubarb',
|
'tpope/vim-sleuth', -- NOTE: This is where your plugins related to LSP can be installed.
|
||||||
|
|
||||||
-- Detect tabstop and shiftwidth automatically
|
|
||||||
'tpope/vim-sleuth',
|
|
||||||
|
|
||||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
|
||||||
-- The configuration is done below. Search for lspconfig to find it below.
|
-- The configuration is done below. Search for lspconfig to find it below.
|
||||||
{ -- LSP Configuration & Plugins
|
{ -- LSP Configuration & Plugins
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
-- Automatically install LSPs to stdpath for neovim
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
-- Useful status updates for LSP
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||||
{ 'j-hui/fidget.nvim', opts = {} },
|
{'j-hui/fidget.nvim', opts = {}}, -- Additional lua configuration, makes nvim stuff amazing!
|
||||||
|
'folke/neodev.nvim'
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
}
|
||||||
'folke/neodev.nvim',
|
}, { -- Autocompletion
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{ -- Autocompletion
|
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
|
dependencies = {'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip'}
|
||||||
},
|
}, -- Useful plugin to show you pending keybinds.
|
||||||
|
{'folke/which-key.nvim', opts = {}},
|
||||||
-- Useful plugin to show you pending keybinds.
|
|
||||||
{ 'folke/which-key.nvim', opts = {} },
|
|
||||||
{ -- Adds git releated signs to the gutter, as well as utilities for managing changes
|
{ -- Adds git releated signs to the gutter, as well as utilities for managing changes
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
opts = {
|
opts = {
|
||||||
-- See `:help gitsigns.txt`
|
-- See `:help gitsigns.txt`
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = '+' },
|
add = {text = '+'},
|
||||||
change = { text = '~' },
|
change = {text = '~'},
|
||||||
delete = { text = '_' },
|
delete = {text = '_'},
|
||||||
topdelete = { text = '‾' },
|
topdelete = {text = '‾'},
|
||||||
changedelete = { text = '~' },
|
changedelete = {text = '~'}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}, { -- Theme inspired by Atom
|
||||||
|
|
||||||
{ -- Theme inspired by Atom
|
|
||||||
'navarasu/onedark.nvim',
|
'navarasu/onedark.nvim',
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
config = function()
|
config = function()
|
||||||
vim.cmd.colorscheme 'onedark'
|
vim.cmd.colorscheme 'onedark'
|
||||||
end,
|
end
|
||||||
},
|
}, { -- Set lualine as statusline
|
||||||
|
|
||||||
{ -- Set lualine as statusline
|
|
||||||
'nvim-lualine/lualine.nvim',
|
'nvim-lualine/lualine.nvim',
|
||||||
-- See `:help lualine.txt`
|
-- See `:help lualine.txt`
|
||||||
opts = {
|
opts = {
|
||||||
|
@ -128,26 +107,17 @@ require('lazy').setup({
|
||||||
icons_enabled = false,
|
icons_enabled = false,
|
||||||
theme = 'onedark',
|
theme = 'onedark',
|
||||||
component_separators = '|',
|
component_separators = '|',
|
||||||
section_separators = '',
|
section_separators = ''
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}, { -- Add indentation guides even on blank lines
|
||||||
|
|
||||||
{ -- Add indentation guides even on blank lines
|
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||||
-- See `:help indent_blankline.txt`
|
-- See `:help indent_blankline.txt`
|
||||||
opts = {
|
opts = {char = '┊', show_trailing_blankline_indent = false}
|
||||||
char = '┊',
|
}, -- "gc" to comment visual regions/lines
|
||||||
show_trailing_blankline_indent = false,
|
{'numToStr/Comment.nvim', opts = {}}, -- Fuzzy Finder (files, lsp, etc)
|
||||||
},
|
{'nvim-telescope/telescope.nvim', version = '*', dependencies = {'nvim-lua/plenary.nvim'}},
|
||||||
},
|
|
||||||
|
|
||||||
-- "gc" to comment visual regions/lines
|
|
||||||
{ 'numToStr/Comment.nvim', opts = {} },
|
|
||||||
|
|
||||||
-- Fuzzy Finder (files, lsp, etc)
|
|
||||||
{ 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } },
|
|
||||||
|
|
||||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
||||||
-- Only load if `make` is available. Make sure you have the system
|
-- Only load if `make` is available. Make sure you have the system
|
||||||
|
@ -159,25 +129,17 @@ require('lazy').setup({
|
||||||
build = 'make',
|
build = 'make',
|
||||||
cond = function()
|
cond = function()
|
||||||
return vim.fn.executable 'make' == 1
|
return vim.fn.executable 'make' == 1
|
||||||
end,
|
end
|
||||||
},
|
}, { -- Highlight, edit, and navigate code
|
||||||
|
|
||||||
{ -- Highlight, edit, and navigate code
|
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
dependencies = {
|
dependencies = {'nvim-treesitter/nvim-treesitter-textobjects'},
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
||||||
},
|
|
||||||
config = function()
|
config = function()
|
||||||
pcall(require('nvim-treesitter.install').update { with_sync = true })
|
pcall(require('nvim-treesitter.install').update {with_sync = true})
|
||||||
end,
|
end
|
||||||
},
|
}, -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||||
|
|
||||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
|
||||||
-- These are some example plugins that I've included in the kickstart repository.
|
-- These are some example plugins that I've included in the kickstart repository.
|
||||||
-- Uncomment any of the lines below to enable them.
|
-- Uncomment any of the lines below to enable them.
|
||||||
require 'kickstart.plugins.autoformat',
|
-- require 'kickstart.plugins.autoformat', -- require 'kickstart.plugins.debug',
|
||||||
-- require 'kickstart.plugins.debug',
|
|
||||||
|
|
||||||
-- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
-- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||||
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
|
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
|
||||||
-- up-to-date with whatever is in the kickstart repo.
|
-- up-to-date with whatever is in the kickstart repo.
|
||||||
|
@ -186,7 +148,7 @@ require('lazy').setup({
|
||||||
--
|
--
|
||||||
-- An additional note is that if you only copied in the `init.lua`, you can just comment this line
|
-- An additional note is that if you only copied in the `init.lua`, you can just comment this line
|
||||||
-- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`.
|
-- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`.
|
||||||
{ import = 'custom.plugins' },
|
{import = 'custom.plugins'}
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
|
@ -234,75 +196,71 @@ vim.o.termguicolors = true
|
||||||
|
|
||||||
-- Keymaps for better default experience
|
-- Keymaps for better default experience
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
vim.keymap.set({'n', 'v'}, '<Space>', '<Nop>', {silent = true})
|
||||||
|
|
||||||
-- Remap for dealing with word wrap
|
-- Remap for dealing with word wrap
|
||||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", {expr = true, silent = true})
|
||||||
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", {expr = true, silent = true})
|
||||||
|
|
||||||
-- [[ Highlight on yank ]]
|
-- [[ Highlight on yank ]]
|
||||||
-- See `:help vim.highlight.on_yank()`
|
-- See `:help vim.highlight.on_yank()`
|
||||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', {clear = true})
|
||||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.highlight.on_yank()
|
||||||
end,
|
end,
|
||||||
group = highlight_group,
|
group = highlight_group,
|
||||||
pattern = '*',
|
pattern = '*'
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Configure Telescope ]]
|
-- [[ Configure Telescope ]]
|
||||||
-- See `:help telescope` and `:help telescope.setup()`
|
-- See `:help telescope` and `:help telescope.setup()`
|
||||||
require('telescope').setup {
|
require('telescope').setup {defaults = {mappings = {i = {['<C-u>'] = false, ['<C-d>'] = false}}}}
|
||||||
defaults = {
|
|
||||||
mappings = {
|
|
||||||
i = {
|
|
||||||
['<C-u>'] = false,
|
|
||||||
['<C-d>'] = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(require('telescope').load_extension, 'fzf')
|
pcall(require('telescope').load_extension, 'fzf')
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
-- See `:help telescope.builtin`
|
||||||
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles,
|
||||||
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
{desc = '[?] Find recently opened files'})
|
||||||
|
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers,
|
||||||
|
{desc = '[ ] Find existing buffers'})
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
vim.keymap.set('n', '<leader>/', function()
|
||||||
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
||||||
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
require('telescope.builtin').current_buffer_fuzzy_find(
|
||||||
winblend = 10,
|
require('telescope.themes').get_dropdown {winblend = 10, previewer = false})
|
||||||
previewer = false,
|
end, {desc = '[/] Fuzzily search in current buffer'})
|
||||||
})
|
|
||||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files,
|
||||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
{desc = '[S]earch [F]iles'})
|
||||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
vim.keymap
|
||||||
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
.set('n', '<leader>sh', require('telescope.builtin').help_tags, {desc = '[S]earch [H]elp'})
|
||||||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
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'})
|
||||||
|
|
||||||
-- [[ Configure Treesitter ]]
|
-- [[ Configure Treesitter ]]
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim' },
|
ensure_installed = {'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim'},
|
||||||
|
|
||||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||||
auto_install = false,
|
auto_install = false,
|
||||||
|
|
||||||
highlight = { enable = true },
|
highlight = {enable = true},
|
||||||
indent = { enable = true, disable = { 'python' } },
|
indent = {enable = true, disable = {'python'}},
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
init_selection = '<c-space>',
|
init_selection = '<c-space>',
|
||||||
node_incremental = '<c-space>',
|
node_incremental = '<c-space>',
|
||||||
scope_incremental = '<c-s>',
|
scope_incremental = '<c-s>',
|
||||||
node_decremental = '<M-space>',
|
node_decremental = '<M-space>'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
textobjects = {
|
textobjects = {
|
||||||
select = {
|
select = {
|
||||||
|
@ -315,39 +273,23 @@ require('nvim-treesitter.configs').setup {
|
||||||
['af'] = '@function.outer',
|
['af'] = '@function.outer',
|
||||||
['if'] = '@function.inner',
|
['if'] = '@function.inner',
|
||||||
['ac'] = '@class.outer',
|
['ac'] = '@class.outer',
|
||||||
['ic'] = '@class.inner',
|
['ic'] = '@class.inner'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
move = {
|
move = {
|
||||||
enable = true,
|
enable = true,
|
||||||
set_jumps = true, -- whether to set jumps in the jumplist
|
set_jumps = true, -- whether to set jumps in the jumplist
|
||||||
goto_next_start = {
|
goto_next_start = {[']m'] = '@function.outer', [']]'] = '@class.outer'},
|
||||||
[']m'] = '@function.outer',
|
goto_next_end = {[']M'] = '@function.outer', [']['] = '@class.outer'},
|
||||||
[']]'] = '@class.outer',
|
goto_previous_start = {['[m'] = '@function.outer', ['[['] = '@class.outer'},
|
||||||
},
|
goto_previous_end = {['[M'] = '@function.outer', ['[]'] = '@class.outer'}
|
||||||
goto_next_end = {
|
|
||||||
[']M'] = '@function.outer',
|
|
||||||
[']['] = '@class.outer',
|
|
||||||
},
|
|
||||||
goto_previous_start = {
|
|
||||||
['[m'] = '@function.outer',
|
|
||||||
['[['] = '@class.outer',
|
|
||||||
},
|
|
||||||
goto_previous_end = {
|
|
||||||
['[M'] = '@function.outer',
|
|
||||||
['[]'] = '@class.outer',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
swap = {
|
swap = {
|
||||||
enable = true,
|
enable = true,
|
||||||
swap_next = {
|
swap_next = {['<leader>a'] = '@parameter.inner'},
|
||||||
['<leader>a'] = '@parameter.inner',
|
swap_previous = {['<leader>A'] = '@parameter.inner'}
|
||||||
},
|
}
|
||||||
swap_previous = {
|
}
|
||||||
['<leader>A'] = '@parameter.inner',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
-- Diagnostic keymaps
|
||||||
|
@ -366,11 +308,9 @@ local on_attach = function(_, bufnr)
|
||||||
-- In this case, we create a function that lets us more easily define mappings specific
|
-- In this case, we create a function that lets us more easily define mappings specific
|
||||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||||
local nmap = function(keys, func, desc)
|
local nmap = function(keys, func, desc)
|
||||||
if desc then
|
if desc then desc = 'LSP: ' .. desc end
|
||||||
desc = 'LSP: ' .. desc
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
vim.keymap.set('n', keys, func, {buffer = bufnr, desc = desc})
|
||||||
end
|
end
|
||||||
|
|
||||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
|
@ -381,7 +321,8 @@ local on_attach = function(_, bufnr)
|
||||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols,
|
||||||
|
'[W]orkspace [S]ymbols')
|
||||||
|
|
||||||
-- See `:help K` for why this keymap
|
-- See `:help K` for why this keymap
|
||||||
-- nmap('<leader>k', vim.lsp.buf.hover, 'Hover Documentation')
|
-- nmap('<leader>k', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
|
@ -412,13 +353,9 @@ local servers = {
|
||||||
-- pyright = {},
|
-- pyright = {},
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
tsserver = {},
|
tsserver = {},
|
||||||
|
cssls = {},
|
||||||
lua_ls = {
|
html = {},
|
||||||
Lua = {
|
lua_ls = {Lua = {workspace = {checkThirdParty = false}, telemetry = {enable = false}}}
|
||||||
workspace = { checkThirdParty = false },
|
|
||||||
telemetry = { enable = false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Setup neovim lua configuration
|
-- Setup neovim lua configuration
|
||||||
|
@ -434,18 +371,16 @@ require('mason').setup()
|
||||||
-- Ensure the servers above are installed
|
-- Ensure the servers above are installed
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
local mason_lspconfig = require 'mason-lspconfig'
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
mason_lspconfig.setup {ensure_installed = vim.tbl_keys(servers)}
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
|
||||||
}
|
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
mason_lspconfig.setup_handlers {
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require('lspconfig')[server_name].setup {
|
require('lspconfig')[server_name].setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
settings = servers[server_name],
|
settings = servers[server_name]
|
||||||
}
|
}
|
||||||
end,
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
|
@ -458,16 +393,13 @@ cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete {},
|
['<C-Space>'] = cmp.mapping.complete {},
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
['<CR>'] = cmp.mapping.confirm {behavior = cmp.ConfirmBehavior.Replace, select = true},
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
|
@ -476,7 +408,7 @@ cmp.setup {
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { 'i', 's' }),
|
end, {'i', 's'}),
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
|
@ -485,12 +417,9 @@ cmp.setup {
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { 'i', 's' }),
|
end, {'i', 's'})
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
},
|
},
|
||||||
|
sources = {{name = 'nvim_lsp'}, {name = 'luasnip'}}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
|
|
|
@ -27,6 +27,7 @@ return {
|
||||||
|
|
||||||
local lsp_formatting = function(bufnr)
|
local lsp_formatting = function(bufnr)
|
||||||
vim.lsp.buf.format({
|
vim.lsp.buf.format({
|
||||||
|
-- async = true,
|
||||||
filter = function(client)
|
filter = function(client)
|
||||||
-- apply whatever logic you want (in this example, we'll only use null-ls)
|
-- apply whatever logic you want (in this example, we'll only use null-ls)
|
||||||
return client.name == "null-ls"
|
return client.name == "null-ls"
|
||||||
|
@ -39,6 +40,9 @@ return {
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
|
-- if client.name == "tsserver" or client.name == "cssls" or client.name == "html" then
|
||||||
|
-- client.server_capabilities.documentFormattingProvider = false -- 0.8 and later
|
||||||
|
-- end
|
||||||
if client.supports_method("textDocument/formatting") then
|
if client.supports_method("textDocument/formatting") then
|
||||||
vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr})
|
vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr})
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
|
|
@ -1,29 +1,37 @@
|
||||||
return {
|
return {
|
||||||
'nvim-telescope/telescope.nvim',
|
'nvim-telescope/telescope.nvim',
|
||||||
version = '*',
|
version = '*',
|
||||||
dependencies = {'nvim-lua/plenary.nvim'},
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
config = function()
|
config = function()
|
||||||
-- Find files using lua fuctions
|
-- Find files using lua fuctions
|
||||||
local opts = {silent = true, noremap = true}
|
local opts = { silent = true, noremap = true }
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>ff',
|
vim.api.nvim_set_keymap('n', '<Leader>ff',
|
||||||
"<Cmd>lua require'telescope.builtin'.find_files()<CR>",
|
"<Cmd>lua require'telescope.builtin'.find_files({ hidden = true })<CR>",
|
||||||
{silent = false, noremap = true})
|
{ silent = false, noremap = true })
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>fg',
|
vim.api.nvim_set_keymap('n', '<Leader>fg',
|
||||||
"<Cmd>lua require'telescope.builtin'.live_grep()<CR>", opts)
|
"<Cmd>lua require'telescope.builtin'.live_grep()<CR>",
|
||||||
|
opts)
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>fs',
|
vim.api.nvim_set_keymap('n', '<Leader>fs',
|
||||||
"<Cmd>lua require'telescope.builtin'.grep_string()<CR>", opts)
|
"<Cmd>lua require'telescope.builtin'.grep_string()<CR>",
|
||||||
|
opts)
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>ft',
|
vim.api.nvim_set_keymap('n', '<Leader>ft',
|
||||||
"<Cmd>lua require'telescope.builtin'.file_browser()<CR>", opts)
|
"<Cmd>lua require'telescope.builtin'.file_browser()<CR>",
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>fo', "<Cmd>lua require'telescope.builtin'.oldfiles()<CR>",
|
opts)
|
||||||
|
vim.api.nvim_set_keymap('n', '<Leader>fo',
|
||||||
|
"<Cmd>lua require'telescope.builtin'.oldfiles()<CR>",
|
||||||
opts)
|
opts)
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>gc',
|
vim.api.nvim_set_keymap('n', '<Leader>gc',
|
||||||
"<Cmd>lua require'telescope.builtin'.git_commits()<CR>", opts)
|
"<Cmd>lua require'telescope.builtin'.git_commits()<CR>",
|
||||||
|
opts)
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>gb',
|
vim.api.nvim_set_keymap('n', '<Leader>gb',
|
||||||
"<Cmd>lua require'telescope.builtin'.git_branches()<CR>", opts)
|
"<Cmd>lua require'telescope.builtin'.git_branches()<CR>",
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>fb', "<Cmd>lua require'telescope.builtin'.buffers()<CR>",
|
opts)
|
||||||
|
vim.api.nvim_set_keymap('n', '<Leader>fb',
|
||||||
|
"<Cmd>lua require'telescope.builtin'.buffers()<CR>",
|
||||||
opts)
|
opts)
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>fh',
|
vim.api.nvim_set_keymap('n', '<Leader>fh',
|
||||||
"<Cmd>lua require'telescope.builtin'.help_tags()<CR>", opts)
|
"<Cmd>lua require'telescope.builtin'.help_tags()<CR>",
|
||||||
|
opts)
|
||||||
|
|
||||||
local actions = require('telescope.actions')
|
local actions = require('telescope.actions')
|
||||||
require('telescope').setup {
|
require('telescope').setup {
|
||||||
|
@ -40,21 +48,21 @@ return {
|
||||||
selection_strategy = 'reset', -- what happens to selection when list changes
|
selection_strategy = 'reset', -- what happens to selection when list changes
|
||||||
sorting_strategy = 'ascending', -- start with most important search on top
|
sorting_strategy = 'ascending', -- start with most important search on top
|
||||||
layout_strategy = 'horizontal', -- vertical layout
|
layout_strategy = 'horizontal', -- vertical layout
|
||||||
layout_config = {prompt_position = 'top'},
|
layout_config = { prompt_position = 'top' },
|
||||||
file_sorter = require'telescope.sorters'.get_fuzzy_file,
|
file_sorter = require 'telescope.sorters'.get_fuzzy_file,
|
||||||
file_ignore_patterns = {'node_modules/.*'}, -- never search in node_modules/ dir
|
file_ignore_patterns = { 'node_modules/.*', '.git/.*' }, -- never search in node_modules/ dir
|
||||||
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
|
generic_sorter = require 'telescope.sorters'.get_generic_fuzzy_sorter,
|
||||||
display_path = true,
|
display_path = true,
|
||||||
winblend = 0, -- window should not be transparent
|
winblend = 0, -- window should not be transparent
|
||||||
border = {}, -- no border?
|
border = {}, -- no border?
|
||||||
borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'}, -- border chars
|
borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, -- border chars
|
||||||
color_devicons = true, -- colorize used icons
|
color_devicons = true, -- colorize used icons
|
||||||
use_less = true, -- less is bash program for preview file contents
|
use_less = true, -- less is bash program for preview file contents
|
||||||
set_env = {['COLORTERM'] = 'truecolor'}, -- use all the colors
|
set_env = { ['COLORTERM'] = 'truecolor' }, -- use all the colors
|
||||||
file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
|
file_previewer = require 'telescope.previewers'.vim_buffer_cat.new,
|
||||||
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
|
grep_previewer = require 'telescope.previewers'.vim_buffer_vimgrep.new,
|
||||||
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
|
qflist_previewer = require 'telescope.previewers'.vim_buffer_qflist.new,
|
||||||
buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
|
buffer_previewer_maker = require 'telescope.previewers'.buffer_previewer_maker,
|
||||||
-- preview_cutoff = 120,
|
-- preview_cutoff = 120,
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
|
@ -72,7 +80,7 @@ return {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extensions = {fzy_native = {override_generic_sorter = false, override_file_sorter = true}}
|
extensions = { fzy_native = { override_generic_sorter = false, override_file_sorter = true } }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue