remove obsolete config and autoformat
This commit is contained in:
parent
8a348282a4
commit
a35b743b62
11 changed files with 165 additions and 160 deletions
1
init.lua
1
init.lua
|
@ -5,6 +5,5 @@ vim.g.mapleader = ' '
|
||||||
require('settings')
|
require('settings')
|
||||||
require('plugins')
|
require('plugins')
|
||||||
require('lsp')
|
require('lsp')
|
||||||
require('filetypes')
|
|
||||||
require('theme')
|
require('theme')
|
||||||
require('keymappings')
|
require('keymappings')
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
vim.cmd([[
|
|
||||||
autocmd BufRead,BufNewFile *.bu set filetype=yaml
|
|
||||||
autocmd BufRead,BufNewFile *.ign set filetype=json
|
|
||||||
]])
|
|
23
lua/lsp.lua
23
lua/lsp.lua
|
@ -13,6 +13,9 @@ local on_attach = function(client, bufnr)
|
||||||
utils.map("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
|
utils.map("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
|
||||||
utils.map("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>")
|
utils.map("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>")
|
||||||
|
|
||||||
|
-- use vim's default coloring
|
||||||
|
client.server_capabilities.semanticTokensProvider = nil
|
||||||
|
|
||||||
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", {
|
||||||
|
@ -30,18 +33,18 @@ local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
||||||
-- LSPs
|
-- LSPs
|
||||||
local servers = {
|
local servers = {
|
||||||
"clangd",
|
"clangd",
|
||||||
"gleam",
|
"gleam",
|
||||||
"lua_ls",
|
"lua_ls",
|
||||||
"ocamllsp",
|
"ocamllsp",
|
||||||
"pyright",
|
"pyright",
|
||||||
"rnix",
|
"rnix",
|
||||||
"ruff_lsp",
|
"ruff_lsp",
|
||||||
"terraformls",
|
"terraformls",
|
||||||
"vimls",
|
"vimls",
|
||||||
}
|
}
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
nvim_lsp[lsp].setup {capabilities = capabilities, on_attach = on_attach}
|
nvim_lsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
|
||||||
end
|
end
|
||||||
|
|
||||||
nvim_lsp.rust_analyzer.setup({
|
nvim_lsp.rust_analyzer.setup({
|
||||||
|
|
|
@ -58,35 +58,37 @@ cmp.setup({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
completion = cmp.config.window.bordered(),
|
completion = cmp.config.window.bordered(),
|
||||||
documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
completion = {
|
completion = {
|
||||||
autocomplete = false,
|
autocomplete = false,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-x><C-o>'] = cmp.mapping.complete(),
|
['<C-x><C-o>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
-- Accept currently selected item.
|
||||||
|
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'luasnip' }, -- For luasnip users.
|
{ name = 'luasnip' },
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
-- Set configuration for specific filetype.
|
||||||
--cmp.setup.filetype('gitcommit', {
|
cmp.setup.filetype('gitcommit', {
|
||||||
-- sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
{ name = 'git' },
|
||||||
-- }, {
|
}, {
|
||||||
-- { name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
-- })
|
})
|
||||||
--})
|
})
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
require('gitsigns').setup {
|
require('gitsigns').setup {
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
local gs = package.loaded.gitsigns
|
local gs = package.loaded.gitsigns
|
||||||
|
|
||||||
local function map(mode, l, r, opts)
|
local function map(mode, l, r, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
opts.buffer = bufnr
|
opts.buffer = bufnr
|
||||||
vim.keymap.set(mode, l, r, opts)
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Navigation
|
||||||
|
map('n', ']c', function()
|
||||||
|
if vim.wo.diff then return ']c' end
|
||||||
|
vim.schedule(function() gs.next_hunk() end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
|
map('n', '[c', function()
|
||||||
|
if vim.wo.diff then return '[c' end
|
||||||
|
vim.schedule(function() gs.prev_hunk() end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
|
-- Actions
|
||||||
|
map('n', '<leader>hs', gs.stage_hunk)
|
||||||
|
map('n', '<leader>hr', gs.reset_hunk)
|
||||||
|
map('v', '<leader>hs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
|
||||||
|
map('v', '<leader>hr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
|
||||||
|
map('n', '<leader>hS', gs.stage_buffer)
|
||||||
|
map('n', '<leader>hu', gs.undo_stage_hunk)
|
||||||
|
map('n', '<leader>hR', gs.reset_buffer)
|
||||||
|
map('n', '<leader>hp', gs.preview_hunk)
|
||||||
|
map('n', '<leader>hb', function() gs.blame_line { full = true } end)
|
||||||
|
map('n', '<leader>tb', gs.toggle_current_line_blame)
|
||||||
|
map('n', '<leader>hd', gs.diffthis)
|
||||||
|
map('n', '<leader>hD', function() gs.diffthis('~') end)
|
||||||
|
map('n', '<leader>td', gs.toggle_deleted)
|
||||||
|
|
||||||
|
-- Text object
|
||||||
|
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Navigation
|
|
||||||
map('n', ']c', function()
|
|
||||||
if vim.wo.diff then return ']c' end
|
|
||||||
vim.schedule(function() gs.next_hunk() end)
|
|
||||||
return '<Ignore>'
|
|
||||||
end, {expr=true})
|
|
||||||
|
|
||||||
map('n', '[c', function()
|
|
||||||
if vim.wo.diff then return '[c' end
|
|
||||||
vim.schedule(function() gs.prev_hunk() end)
|
|
||||||
return '<Ignore>'
|
|
||||||
end, {expr=true})
|
|
||||||
|
|
||||||
-- Actions
|
|
||||||
map('n', '<leader>hs', gs.stage_hunk)
|
|
||||||
map('n', '<leader>hr', gs.reset_hunk)
|
|
||||||
map('v', '<leader>hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
|
|
||||||
map('v', '<leader>hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
|
|
||||||
map('n', '<leader>hS', gs.stage_buffer)
|
|
||||||
map('n', '<leader>hu', gs.undo_stage_hunk)
|
|
||||||
map('n', '<leader>hR', gs.reset_buffer)
|
|
||||||
map('n', '<leader>hp', gs.preview_hunk)
|
|
||||||
map('n', '<leader>hb', function() gs.blame_line{full=true} end)
|
|
||||||
map('n', '<leader>tb', gs.toggle_current_line_blame)
|
|
||||||
map('n', '<leader>hd', gs.diffthis)
|
|
||||||
map('n', '<leader>hD', function() gs.diffthis('~') end)
|
|
||||||
map('n', '<leader>td', gs.toggle_deleted)
|
|
||||||
|
|
||||||
-- Text object
|
|
||||||
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,88 +1,86 @@
|
||||||
require('plugins.packer_setup')
|
require('plugins.packer_setup')
|
||||||
|
|
||||||
require('packer').startup(function()
|
require('packer').startup(function()
|
||||||
|
-- Packer can manage itself as an optional plugin
|
||||||
|
use { 'wbthomason/packer.nvim', opt = true }
|
||||||
|
|
||||||
-- Packer can manage itself as an optional plugin
|
-- Fuzzy finder
|
||||||
use {'wbthomason/packer.nvim', opt = true }
|
use {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
requires = {
|
||||||
|
{ 'nvim-lua/popup.nvim' },
|
||||||
|
{ 'nvim-lua/plenary.nvim' },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Fuzzy finder
|
-- Autocomplete and snippets
|
||||||
use {
|
use {
|
||||||
'nvim-telescope/telescope.nvim',
|
'hrsh7th/nvim-cmp',
|
||||||
requires = {
|
requires = {
|
||||||
{'nvim-lua/popup.nvim'},
|
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||||
{'nvim-lua/plenary.nvim'},
|
{ 'hrsh7th/cmp-buffer' },
|
||||||
}
|
{ 'hrsh7th/cmp-path' },
|
||||||
}
|
{ 'hrsh7th/cmp-cmdline' },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
use { 'L3MON4D3/LuaSnip',
|
||||||
|
config = function()
|
||||||
|
local snippet_path = os.getenv("HOME") .. "/.config/nvim/snippets/"
|
||||||
|
if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then
|
||||||
|
vim.opt.rtp:append(snippet_path)
|
||||||
|
end
|
||||||
|
|
||||||
-- Autocomplete and snippets
|
require("luasnip").config.set_config({
|
||||||
use {
|
history = true,
|
||||||
'hrsh7th/nvim-cmp',
|
updateevents = "TextChanged,TextChangedI",
|
||||||
requires = {
|
delete_check_events = "TextChanged,InsertLeave",
|
||||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
})
|
||||||
{ 'hrsh7th/cmp-buffer' },
|
require("luasnip.loaders.from_lua").lazy_load()
|
||||||
{ 'hrsh7th/cmp-path' },
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
{ 'hrsh7th/cmp-cmdline' },
|
require("luasnip.loaders.from_snipmate").lazy_load()
|
||||||
}
|
end,
|
||||||
}
|
requires = {
|
||||||
use { 'L3MON4D3/LuaSnip',
|
{ "rafamadriz/friendly-snippets" },
|
||||||
config = function ()
|
{ 'saadparwaiz1/cmp_luasnip' },
|
||||||
local snippet_path = os.getenv("HOME") .. "/.config/nvim/snippets/"
|
{ "benfowler/telescope-luasnip.nvim" },
|
||||||
if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then
|
},
|
||||||
vim.opt.rtp:append(snippet_path)
|
}
|
||||||
end
|
|
||||||
|
|
||||||
require("luasnip").config.set_config({
|
-- Statusbar, colors and syntax
|
||||||
history = true,
|
use { 'vim-airline/vim-airline' }
|
||||||
updateevents = "TextChanged,TextChangedI",
|
use { 'vim-airline/vim-airline-themes' }
|
||||||
delete_check_events = "TextChanged,InsertLeave",
|
|
||||||
})
|
|
||||||
require("luasnip.loaders.from_lua").lazy_load()
|
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
|
||||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
|
||||||
end,
|
|
||||||
requires = {
|
|
||||||
{ "rafamadriz/friendly-snippets" },
|
|
||||||
{ 'saadparwaiz1/cmp_luasnip' },
|
|
||||||
{ "benfowler/telescope-luasnip.nvim" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Statusbar, colors and syntax
|
-- LSP and related
|
||||||
use { 'vim-airline/vim-airline' }
|
use { 'neovim/nvim-lspconfig' }
|
||||||
use { 'vim-airline/vim-airline-themes' }
|
use { 'aznhe21/actions-preview.nvim',
|
||||||
|
config = function()
|
||||||
|
vim.keymap.set("n", "<space>ca", require("actions-preview").code_actions)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
use { 'folke/trouble.nvim' } -- lsp diagnostics
|
||||||
|
|
||||||
-- LSP and related
|
-- Plugins to extend builtin language support
|
||||||
use { 'neovim/nvim-lspconfig' }
|
use { 'cespare/vim-toml' }
|
||||||
use { 'aznhe21/actions-preview.nvim',
|
use { 'gleam-lang/gleam.vim' }
|
||||||
config = function()
|
use { 'rust-lang/rust.vim' }
|
||||||
vim.keymap.set("n", "<space>ca", require("actions-preview").code_actions)
|
use { 'folke/neodev.nvim' }
|
||||||
end,
|
|
||||||
}
|
|
||||||
use { 'folke/trouble.nvim' } -- lsp diagnostics
|
|
||||||
|
|
||||||
-- Plugins to extend builtin language support
|
-- Git
|
||||||
use { 'cespare/vim-toml' }
|
use {
|
||||||
use { 'gleam-lang/gleam.vim' }
|
'NeogitOrg/neogit',
|
||||||
use { 'rust-lang/rust.vim' }
|
requires = {
|
||||||
use { 'folke/neodev.nvim' }
|
{ "nvim-lua/plenary.nvim" },
|
||||||
|
{ "sindrets/diffview.nvim" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
use { "lewis6991/gitsigns.nvim" }
|
||||||
|
|
||||||
-- Git
|
-- Filesystem browser
|
||||||
use {
|
use { 'stevearc/oil.nvim' }
|
||||||
'NeogitOrg/neogit',
|
|
||||||
requires = {
|
|
||||||
{ "nvim-lua/plenary.nvim" },
|
|
||||||
{ "sindrets/diffview.nvim" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
use { "lewis6991/gitsigns.nvim" }
|
|
||||||
|
|
||||||
-- Filesystem browser
|
|
||||||
use { 'stevearc/oil.nvim' }
|
|
||||||
|
|
||||||
-- Misc
|
|
||||||
use { 'jbyuki/venn.nvim' } -- ascii diagrams
|
|
||||||
use { 'hashivim/vim-terraform' }
|
|
||||||
|
|
||||||
|
-- Misc
|
||||||
|
use { 'jbyuki/venn.nvim' } -- ascii diagrams
|
||||||
|
use { 'hashivim/vim-terraform' }
|
||||||
end)
|
end)
|
||||||
|
|
||||||
require('plugins.cmp')
|
require('plugins.cmp')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local neogit = require('neogit')
|
local neogit = require('neogit')
|
||||||
|
|
||||||
neogit.setup { }
|
neogit.setup {}
|
||||||
|
|
||||||
vim.keymap.set('n', '<C-x><C-g>', neogit.open, {})
|
vim.keymap.set('n', '<C-x><C-g>', neogit.open, {})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
-- Auto install packer.nvim if not exists
|
-- Auto install packer.nvim if not exists
|
||||||
local install_path = vim.fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
|
local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
|
||||||
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
||||||
vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim '..install_path)
|
vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd [[packadd packer.nvim]]
|
vim.cmd [[packadd packer.nvim]]
|
||||||
|
|
|
@ -3,19 +3,20 @@ function _G.Toggle_venn()
|
||||||
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
||||||
if venn_enabled == "nil" then
|
if venn_enabled == "nil" then
|
||||||
vim.b.venn_enabled = true
|
vim.b.venn_enabled = true
|
||||||
vim.cmd[[setlocal ve=all]]
|
vim.cmd [[setlocal ve=all]]
|
||||||
-- draw a line on HJKL keystokes
|
-- draw a line on HJKL keystokes
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
|
||||||
-- draw a box by pressing "f" with visual selection
|
-- draw a box by pressing "f" with visual selection
|
||||||
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
|
||||||
else
|
else
|
||||||
vim.cmd[[setlocal ve=]]
|
vim.cmd [[setlocal ve=]]
|
||||||
vim.cmd[[mapclear <buffer>]]
|
vim.cmd [[mapclear <buffer>]]
|
||||||
vim.b.venn_enabled = nil
|
vim.b.venn_enabled = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- toggle keymappings for venn using <leader>v
|
-- toggle keymappings for venn using <leader>v
|
||||||
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true})
|
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true })
|
||||||
|
|
|
@ -33,3 +33,9 @@ vim.opt.undofile = true
|
||||||
-- Enable vimrc files per project and disable unsafe commands in project vimrc
|
-- Enable vimrc files per project and disable unsafe commands in project vimrc
|
||||||
vim.opt.exrc = true
|
vim.opt.exrc = true
|
||||||
vim.opt.secure = true
|
vim.opt.secure = true
|
||||||
|
|
||||||
|
-- unknown filetypes mappings
|
||||||
|
vim.cmd([[
|
||||||
|
autocmd BufRead,BufNewFile *.bu set filetype=yaml
|
||||||
|
autocmd BufRead,BufNewFile *.ign set filetype=json
|
||||||
|
]])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local utils = { }
|
local utils = {}
|
||||||
|
|
||||||
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
|
local scopes = { o = vim.o, b = vim.bo, w = vim.wo }
|
||||||
|
|
||||||
function utils.opt(scope, key, value)
|
function utils.opt(scope, key, value)
|
||||||
scopes[scope][key] = value
|
scopes[scope][key] = value
|
||||||
|
@ -8,9 +8,9 @@ function utils.opt(scope, key, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function utils.map(mode, lhs, rhs, opts)
|
function utils.map(mode, lhs, rhs, opts)
|
||||||
local options = { noremap = true, silent = true }
|
local options = { noremap = true, silent = true }
|
||||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
return utils
|
return utils
|
||||||
|
|
Loading…
Reference in a new issue