-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
120 lines (101 loc) · 3.38 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
local vim = vim
vim.g.mapleader = ";"
vim.cmd("set clipboard=unnamedplus")
vim.cmd("set nowrap")
vim.opt.ignorecase = true
vim.opt.hlsearch = false
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.number = true
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local M = {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
},
}
M.config = function()
local cmp = require("cmp")
vim.opt.completeopt = { "menu", "menuone", "noselect" }
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "buffer" },
}),
})
end
plugins = {
{'nvim-telescope/telescope.nvim', tag = '0.1.4', dependencies = { 'nvim-lua/plenary.nvim' }},
{'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
{"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
{"Shatur/neovim-ayu"},
{"numToStr/Comment.nvim"},
{"neovim/nvim-lspconfig"},
{'phaazon/hop.nvim'},
{'tpope/vim-fugitive'},
{'rebelot/kanagawa.nvim'},
-- {'dasupradyumna/midnight.nvim', lazy = false, priority = 1000},
{'sainnhe/everforest'}, -- Current theme
-- {'github/copilot.vim'},
{'kylechui/nvim-surround', version = "*"},
M,
}
require("lazy").setup(plugins)
require('telescope').load_extension('fzf')
require('nvim-surround').setup({})
vim.wo.signcolumn = "yes" -- Avoids the weird little movement with rust lsp
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>s', ":vsplit<CR>")
vim.keymap.set('n', '<leader><leader>', "<C-W>w<CR>")
vim.keymap.set('n', '<leader>f', builtin.find_files, {})
vim.keymap.set('n', '<leader>g', builtin.live_grep, {})
vim.keymap.set('n', '<leader>d', builtin.diagnostics, {})
-- vim.cmd.colorscheme 'midnight'
vim.cmd [[colorscheme everforest]]
require('Comment').setup()
local on_attach = function(client)
require'completion'.on_attach(client)
end
require("lspconfig").lua_ls.setup {}
require("lspconfig").pyright.setup {}
require("lspconfig").gopls.setup {}
require("lspconfig").zls.setup {}
require("lspconfig").rust_analyzer.setup({
on_attach = on_attach,
settings = {
["rust-analyzer"] = {
},
},
})
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
local opts = {buffer = ev.buf}
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<leader>u', builtin.lsp_references, opts)
vim.keymap.set({ 'n', 'v' }, '<leader>c', vim.lsp.buf.code_action, opts)
end,
})