Compare commits
10 Commits
d54ba8d8c6
...
828205efce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
828205efce | ||
| fcec1cf777 | |||
|
|
adfbfcd0bc | ||
|
|
f241fba3d0 | ||
| fe9236314a | |||
| 7ed76583a0 | |||
| b1ceb62e46 | |||
| aeaf5800ef | |||
| 025676576f | |||
| 52f6ce4fb5 |
@ -25,14 +25,17 @@ Here is a list of all external depencies you'll need:
|
|||||||
|
|
||||||
- universal ctags, ctags won't work (note that arch's universal ctags package is named ctags...), for tagbar
|
- universal ctags, ctags won't work (note that arch's universal ctags package is named ctags...), for tagbar
|
||||||
- tree-sitter, for syntax coloration
|
- tree-sitter, for syntax coloration
|
||||||
- rust-analyzer, as LSP server
|
- rust-analyzer and clangd as LSP servers
|
||||||
|
|
||||||
On arch, you can just use the following command :
|
On arch, you can just use the following command :
|
||||||
```
|
```
|
||||||
pacman -Syu ctags tree-sitter rust-analyzer
|
pacman -Syu ctags tree-sitter rust-analyzer clangd
|
||||||
```
|
```
|
||||||
|
|
||||||
Once the dependencies are installed, type `:checkhealth` to verify that everything is properly detected. You should, at most, see a warning about node and another about the clipboard.
|
Once the dependencies are installed, type `:checkhealth` to verify that everything is properly detected. You should, at most, see a warning about node and another about the clipboard.
|
||||||
|
For clangd to work properly, create a compile_flags.txt file at the root of the project and fill it
|
||||||
|
with the flags used for compilation (one per line). Cpu-specific flags may cause the analysis to
|
||||||
|
fail and should be ignored (e.g. mcpu, mthumb, ...)
|
||||||
|
|
||||||
### Syntax coloration
|
### Syntax coloration
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
vim.o.textwidth = 80
|
vim.o.textwidth = 80
|
||||||
|
|
||||||
|
vim.o.tabstop = 2
|
||||||
|
vim.o.shiftwidth = 2
|
||||||
vim.o.expandtab = true
|
vim.o.expandtab = true
|
||||||
|
|
||||||
-- remove white spaces at end of line
|
-- remove white spaces at end of line
|
||||||
|
|||||||
300
lua/plugins.lua
300
lua/plugins.lua
@ -6,37 +6,49 @@ local has_words_before = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
local feedkey = function(key, mode)
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true),
|
||||||
|
mode, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- plugins definition
|
-- LSP keybindings
|
||||||
local function manage_plugins()
|
local lsp_on_attach = function(_, bufnr)
|
||||||
|
local nmap = function(keys, func, desc)
|
||||||
|
if desc then
|
||||||
|
desc = 'LSP: ' .. desc
|
||||||
|
end
|
||||||
|
|
||||||
local plugins = {
|
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||||
["https://github.com/faerryn/plogins.nvim.git"] = {},
|
|
||||||
["https://github.com/tpope/vim-sensible.git"] = {},
|
|
||||||
["https://github.com/kevinhwang91/rnvimr.git"] = {
|
|
||||||
packadd_hook = function()
|
|
||||||
vim.api.nvim_set_keymap('n', '<leader>f', ":RnvimrToggle<cr>", {})
|
|
||||||
vim.g.rnvimr_action = {
|
|
||||||
['<C-t>'] = "NvimEdit tabedit",
|
|
||||||
['<C-x>'] = "NvimEdit split",
|
|
||||||
['<C-w>'] = "NvimEdit vsplit",
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
},
|
|
||||||
["https://github.com/ojroques/nvim-hardline.git"] = {
|
-- Define standard LSP shortcuts
|
||||||
packadd_hook = function()
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
require('hardline').setup()
|
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||||
|
-- these actions are now handled by Telescope
|
||||||
|
-- nmap('gd', vim.lsp.buf.definition, '[G]oto [d]efinition')
|
||||||
|
-- nmap('gr', vim.lsp.buf.references, '[G]oto [R]eferences')
|
||||||
|
-- nmap('gc', vim.lsp.buf.outgoing_calls, '[G]oto Outgoing [C]alls')
|
||||||
|
-- nmap('gt', vim.lsp.buf.type_definition, '[G]oto [T]ype definition')
|
||||||
|
-- See `:help K` for why this keymap
|
||||||
|
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
|
|
||||||
|
-- Create a command `:Format` local to the LSP buffer
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, 'Format',
|
||||||
|
vim.lsp.buf.format or vim.lsp.buf.formatting,
|
||||||
|
{ desc = 'Format current buffer with LSP' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
plugins = {
|
||||||
|
{ "tpope/vim-sensible", lazy = false },
|
||||||
|
{
|
||||||
|
"EdenEast/nightfox.nvim",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
{ "airblade/vim-gitgutter" },
|
||||||
},
|
},
|
||||||
["https://github.com/EdenEast/nightfox.nvim.git"] = {
|
init = function()
|
||||||
packadd_hook = function()
|
|
||||||
require('nightfox').setup({
|
require('nightfox').setup({
|
||||||
options = {
|
options = {
|
||||||
modules = {
|
modules = { gitgutter = true }
|
||||||
gitgutter = true,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
palettes = {
|
palettes = {
|
||||||
nightfox = {
|
nightfox = {
|
||||||
@ -51,35 +63,47 @@ local function manage_plugins()
|
|||||||
},
|
},
|
||||||
specs = {
|
specs = {
|
||||||
nightfox = {
|
nightfox = {
|
||||||
syntax = {
|
syntax = { func = "red" }
|
||||||
func = "red",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.o.termguicolors = true
|
vim.o.termguicolors = true
|
||||||
vim.cmd("colorscheme nightfox")
|
vim.cmd("colorscheme nightfox")
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
-- Auto-completion
|
"ojroques/nvim-hardline",
|
||||||
["https://github.com/hrsh7th/cmp-nvim-lsp.git"] = {},
|
lazy = false,
|
||||||
["https://github.com/hrsh7th/cmp-buffer.git"] = {},
|
init = function()
|
||||||
["https://github.com/hrsh7th/cmp-path.git"] = {},
|
require('hardline').setup()
|
||||||
["https://github.com/hrsh7th/cmp-cmdline.git"] = {},
|
end,
|
||||||
["https://github.com/hrsh7th/cmp-vsnip.git"] = {},
|
|
||||||
["https://github.com/hrsh7th/vim-vsnip.git"] = {},
|
|
||||||
["https://github.com/hrsh7th/nvim-cmp.git"] = {
|
|
||||||
packadd_after = {
|
|
||||||
["https://github.com/hrsh7th/cmp-nvim-lsp.git"] = true,
|
|
||||||
["https://github.com/hrsh7th/cmp-buffer.git"] = true,
|
|
||||||
["https://github.com/hrsh7th/cmp-path.git"] = true,
|
|
||||||
["https://github.com/hrsh7th/cmp-cmdline.git"] = true,
|
|
||||||
["https://github.com/hrsh7th/cmp-vsnip.git"] = true,
|
|
||||||
["https://github.com/hrsh7th/vim-vsnip.git"] = true,
|
|
||||||
},
|
},
|
||||||
packadd_hook = function()
|
{
|
||||||
|
"kevinhwang91/rnvimr",
|
||||||
|
lazy = false,
|
||||||
|
init = function()
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>f', ":RnvimrToggle<cr>", {})
|
||||||
|
vim.g.rnvimr_action = {
|
||||||
|
['<C-t>'] = "NvimEdit tabedit",
|
||||||
|
['<C-x>'] = "NvimEdit split",
|
||||||
|
['<C-v>'] = "NvimEdit vsplit",
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
{ "hrsh7th/cmp-nvim-lsp" },
|
||||||
|
{ "hrsh7th/cmp-buffer" },
|
||||||
|
{ "hrsh7th/cmp-path" },
|
||||||
|
{ "hrsh7th/cmp-cmdline" },
|
||||||
|
{ "hrsh7th/cmp-nvim-lsp-signature-help" },
|
||||||
|
{ "hrsh7th/cmp-vsnip" },
|
||||||
|
{ "hrsh7th/vim-vsnip" },
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
vim.o.completeopt = "menu,menuone,noselect"
|
vim.o.completeopt = "menu,menuone,noselect"
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
||||||
@ -124,6 +148,7 @@ local function manage_plugins()
|
|||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'nvim_lsp_signature_help' },
|
||||||
{ name = 'vsnip' },
|
{ name = 'vsnip' },
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
@ -155,63 +180,116 @@ local function manage_plugins()
|
|||||||
{ name = 'cmdline' }
|
{ name = 'cmdline' }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
-- LSP configuration
|
|
||||||
["https://github.com/neovim/nvim-lspconfig.git"] = {},
|
|
||||||
["https://github.com/simrat39/rust-tools.nvim.git"] = {
|
|
||||||
packadd_after = {
|
|
||||||
["https://github.com/neovim/nvim-lspconfig.git"] = true,
|
|
||||||
["https://github.com/hrsh7th/nvim-cmp.git"] = true,
|
|
||||||
},
|
|
||||||
packadd_hook = function()
|
|
||||||
local rt = require("rust-tools")
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
||||||
|
|
||||||
rt.setup({
|
|
||||||
server = {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = function(_, bufnr)
|
|
||||||
-- Hover actions
|
|
||||||
vim.keymap.set("n", "<C-space>",
|
|
||||||
rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
||||||
---- Code action groups
|
|
||||||
vim.keymap.set("n", "<Leader>a",
|
|
||||||
rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
{
|
||||||
end
|
"neovim/nvim-lspconfig",
|
||||||
},
|
lazy = false,
|
||||||
|
dependencies = "hrsh7th/nvim-cmp",
|
||||||
|
init = function()
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
local lsp_config = require("lspconfig")
|
||||||
|
local servers = { "clangd", "rust_analyzer", "pylsp" }
|
||||||
|
|
||||||
-- LSP alternative
|
for _, lsp in ipairs(servers) do
|
||||||
["https://github.com/preservim/tagbar.git" ] = {
|
lsp_config[lsp].setup {
|
||||||
packadd_hook = function()
|
capabilities = capabilities,
|
||||||
vim.api.nvim_set_keymap('n', '<leader>t', ":TagbarToggle<cr>", {})
|
on_attach = lsp_on_attach,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
tag = "0.1.2",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
{ "nvim-lua/plenary.nvim" },
|
||||||
|
{ "ludovicchabant/vim-gutentags" },
|
||||||
|
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
require("telescope").setup{
|
||||||
|
defaults = {
|
||||||
|
-- Default configuration for telescope goes here:
|
||||||
|
-- config_key = value,
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
-- map actions.which_key to <C-h> (default: <C-/>)
|
||||||
|
-- actions.which_key shows the mappings for your picker,
|
||||||
|
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
|
||||||
|
["<C-h>"] = "which_key"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pickers = {
|
||||||
|
-- Default configuration for builtin pickers goes here:
|
||||||
|
-- picker_name = {
|
||||||
|
-- picker_config_key = value,
|
||||||
|
-- ...
|
||||||
|
-- }
|
||||||
|
-- Now the picker_config_key will be applied every time you call this
|
||||||
|
-- builtin picker
|
||||||
|
},
|
||||||
|
extensions = {
|
||||||
|
fzf = {
|
||||||
|
fuzzy = true, -- false will only do exact matching
|
||||||
|
override_generic_sorter = true, -- override the generic sorter
|
||||||
|
override_file_sorter = true, -- override the file sorter
|
||||||
|
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||||
|
-- the default case_mode is "smart_case"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require("telescope").load_extension("fzf")
|
||||||
|
|
||||||
-- Git integration
|
vim.api.nvim_set_keymap('n', 'tf',
|
||||||
["https://github.com/tpope/vim-fugitive.git"] = {},
|
":Telescope find_files<cr>", {})
|
||||||
["https://github.com/airblade/vim-gitgutter.git"] = {
|
vim.api.nvim_set_keymap('n', 'tg',
|
||||||
packadd_after = { ["https://github.com/EdenEast/nightfox.nvim.git"] = true },
|
":Telescope live_grep<cr>", {})
|
||||||
packadd_hook = function()
|
vim.api.nvim_set_keymap('n', 'ts',
|
||||||
|
":Telescope grep_string<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'tt',
|
||||||
|
":Telescope current_buffer_tags<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'tc',
|
||||||
|
":Telescope git_commits<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'ta',
|
||||||
|
":Telescope git_status<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'td',
|
||||||
|
":Telescope lsp_definitions<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'tr',
|
||||||
|
":Telescope lsp_references<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'tl',
|
||||||
|
":Telescope lsp_document_symbols<cr>", {})
|
||||||
|
vim.api.nvim_set_keymap('n', 'te',
|
||||||
|
":Telescope diagnostics<cr>", {})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"airblade/vim-gitgutter",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
{ "tpope/vim-fugitive" },
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
-- put sign in number column to avoid screen-shifting
|
-- put sign in number column to avoid screen-shifting
|
||||||
vim.cmd('set signcolumn=number')
|
vim.cmd('set signcolumn=number')
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
["https://github.com/nvim-lua/plenary.nvim.git"] = {},
|
{
|
||||||
["https://github.com/sindrets/diffview.nvim.git"] = {
|
"sindrets/diffview.nvim",
|
||||||
packadd_after = { ["https://github.com/nvim-lua/plenary.nvim.git"] = true },
|
lazy = false,
|
||||||
packadd_hook = function()
|
dependencies = {
|
||||||
|
{ "nvim-lua/plenary.nvim" },
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
vim.api.nvim_set_keymap('n', '<leader>g', ":DiffviewOpen", {})
|
vim.api.nvim_set_keymap('n', '<leader>g', ":DiffviewOpen", {})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
-- Syntax highlight
|
"nvim-treesitter/nvim-treesitter",
|
||||||
["https://github.com/nvim-treesitter/nvim-treesitter.git"] = {
|
lazy = false,
|
||||||
packadd_hook = function()
|
init = function()
|
||||||
local conf = require("nvim-treesitter.configs")
|
local conf = require("nvim-treesitter.configs")
|
||||||
|
|
||||||
conf.setup {
|
conf.setup {
|
||||||
@ -230,7 +308,7 @@ local function manage_plugins()
|
|||||||
disable = {},
|
disable = {},
|
||||||
-- disable slow treesitter highlight for large files
|
-- disable slow treesitter highlight for large files
|
||||||
disable = function(lang, buf)
|
disable = function(lang, buf)
|
||||||
local max_filesize = 100 * 1024 -- 100 KB
|
local max_filesize = 200 * 1024 -- 200 KB
|
||||||
local ok, stats =
|
local ok, stats =
|
||||||
pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||||
if ok and stats and stats.size > max_filesize then
|
if ok and stats and stats.size > max_filesize then
|
||||||
@ -239,37 +317,25 @@ local function manage_plugins()
|
|||||||
end,
|
end,
|
||||||
-- run `:h syntax` and tree-sitter at the same time.
|
-- run `:h syntax` and tree-sitter at the same time.
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
{ "ARM9/arm-syntax-vim", lazy = false },
|
||||||
}
|
}
|
||||||
|
|
||||||
local manager = require("plogins").manage(plugins)
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
vim.api.nvim_create_user_command("PloginsUpgrade",
|
vim.fn.system({
|
||||||
manager.upgrade, {})
|
"git",
|
||||||
vim.api.nvim_create_user_command("PloginsAutoremove",
|
"clone",
|
||||||
manager.autoremove, {})
|
"--filter=blob:none",
|
||||||
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
|
"--branch=stable", -- latest stable release
|
||||||
|
lazypath,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
local plogins_source = "https://github.com/faerryn/plogins.nvim.git"
|
require("lazy").setup(plugins, opts)
|
||||||
local plogins_name = plogins_source:gsub("/", "%%")
|
|
||||||
local plogins_dir = ("%s/site/pack/plogins/opt/%s"):format((vim.fn.stdpath("data")),
|
|
||||||
plogins_name)
|
|
||||||
|
|
||||||
if not vim.loop.fs_stat(plogins_dir) then
|
|
||||||
vim.loop.spawn("git",
|
|
||||||
{ args = { "clone", "--depth", "1", plogins_source, plogins_dir } },
|
|
||||||
function(code, signal)
|
|
||||||
vim.defer_fn(function()
|
|
||||||
vim.cmd(("packadd %s"):format(vim.fn.fnameescape(plogins_name)))
|
|
||||||
manage_plugins()
|
|
||||||
end, 0)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
vim.cmd(("packadd %s"):format(vim.fn.fnameescape(plogins_name)))
|
|
||||||
manage_plugins()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user