You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.0 KiB
119 lines
4.0 KiB
vim.cmd [[packadd packer.nvim]] |
|
|
|
return require('packer').startup(function() |
|
-- packer |
|
use 'wbthomason/packer.vim' |
|
|
|
-- lspconfig |
|
use { |
|
'neovim/nvim-lspconfig', |
|
config = function() |
|
local attachment = function(client, bufnr) |
|
local opts = { noremap=true, silent=true } |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.format({async = true})<CR>', opts) |
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ge', '<cmd>lua vim.diagnostic.open_float()<CR>', opts) |
|
|
|
if client.resolved_capabilities.document_formatting then |
|
vim.api.nvim_command [[augroup Format]] |
|
vim.api.nvim_command [[autocmd! * <buffer>]] |
|
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]] |
|
vim.api.nvim_command [[augroup END]] |
|
end |
|
end |
|
|
|
local servers = { 'pyright', 'rust_analyzer', 'clangd' } |
|
for _, lsp in pairs(servers) do |
|
require('lspconfig')[lsp].setup { |
|
on_attach = attachment |
|
} |
|
end |
|
end, |
|
} |
|
|
|
-- treesitter |
|
use { |
|
'nvim-treesitter/nvim-treesitter', |
|
config = function() |
|
require('nvim-treesitter.configs').setup { |
|
ensure_installed = { "python", "rust" }, |
|
sync_install = false, |
|
highlight = { |
|
enable = true, |
|
}, |
|
} |
|
end, |
|
} |
|
|
|
-- status line |
|
use { |
|
'nvim-lualine/lualine.nvim', |
|
config = function() |
|
require('lualine').setup { |
|
options = { |
|
icons_enabled = true, |
|
-- theme = 'ayu_dark', |
|
theme = 'ayu_mirage', |
|
component_separators = { left = '', right = '' }, |
|
section_separators = { left = '', right = '' }, |
|
disabled_filetypes = {}, |
|
always_divide_middle = true, |
|
}, |
|
sections = { |
|
lualine_a = {'mode'}, |
|
lualine_b = {'filename', 'branch'}, |
|
lualine_c = { |
|
{ |
|
'diagnostics', |
|
symbols = {error = 'Errors:', warn = 'Warns:', info = 'Info:', hint = 'Hints:'}, |
|
sources = { 'nvim_diagnostic' } |
|
} |
|
}, |
|
lualine_w = {'encoding'}, |
|
lualine_x = {'filetype'}, |
|
lualine_y = {'progress'}, |
|
lualine_z = {'location'} |
|
}, |
|
inactive_sections = { |
|
lualine_a = {}, |
|
lualine_b = {}, |
|
lualine_c = {'filename'}, |
|
lualine_x = {'location'}, |
|
lualine_y = {}, |
|
lualine_z = {} |
|
}, |
|
tabline = { |
|
lualine_a = {'tabs'}, |
|
lualine_b = {}, |
|
lualine_c = {}, |
|
lualine_x = {}, |
|
lualine_y = {}, |
|
lualine_z = {} |
|
}, |
|
extensions = {} |
|
} |
|
end |
|
} |
|
|
|
use { |
|
'nvim-telescope/telescope.nvim', |
|
requires = { {'nvim-lua/plenary.nvim'} }, |
|
config = function() |
|
vim.api.nvim_set_keymap('n', '<leader><space>', '<cmd>Telescope find_files<CR>', { noremap = true, silent = true }) |
|
vim.api.nvim_set_keymap('n', '<leader>g', '<cmd>Telescope live_grep<CR>', { noremap = true, silent = true }) |
|
end, |
|
} |
|
|
|
use 'windwp/nvim-autopairs' |
|
end)
|
|
|