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('plugins')
|
||||
require('lsp')
|
||||
require('filetypes')
|
||||
require('theme')
|
||||
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>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
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
|
@ -30,18 +33,18 @@ local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|||
|
||||
-- LSPs
|
||||
local servers = {
|
||||
"clangd",
|
||||
"gleam",
|
||||
"lua_ls",
|
||||
"ocamllsp",
|
||||
"pyright",
|
||||
"rnix",
|
||||
"ruff_lsp",
|
||||
"terraformls",
|
||||
"vimls",
|
||||
"clangd",
|
||||
"gleam",
|
||||
"lua_ls",
|
||||
"ocamllsp",
|
||||
"pyright",
|
||||
"rnix",
|
||||
"ruff_lsp",
|
||||
"terraformls",
|
||||
"vimls",
|
||||
}
|
||||
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
|
||||
|
||||
nvim_lsp.rust_analyzer.setup({
|
||||
|
|
|
@ -58,35 +58,37 @@ cmp.setup({
|
|||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
completion = {
|
||||
autocomplete = false,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-x><C-o>'] = cmp.mapping.complete(),
|
||||
['<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.
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-x><C-o>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
-- Accept currently selected item.
|
||||
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
--cmp.setup.filetype('gitcommit', {
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
-- }, {
|
||||
-- { name = 'buffer' },
|
||||
-- })
|
||||
--})
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
require('gitsigns').setup {
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
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
|
||||
|
||||
-- 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('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
|
||||
use {'wbthomason/packer.nvim', opt = true }
|
||||
-- Fuzzy finder
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {
|
||||
{ 'nvim-lua/popup.nvim' },
|
||||
{ 'nvim-lua/plenary.nvim' },
|
||||
}
|
||||
}
|
||||
|
||||
-- Fuzzy finder
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {
|
||||
{'nvim-lua/popup.nvim'},
|
||||
{'nvim-lua/plenary.nvim'},
|
||||
}
|
||||
}
|
||||
-- Autocomplete and snippets
|
||||
use {
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ '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
|
||||
use {
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ '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
|
||||
require("luasnip").config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
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" },
|
||||
},
|
||||
}
|
||||
|
||||
require("luasnip").config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
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
|
||||
use { 'vim-airline/vim-airline' }
|
||||
use { 'vim-airline/vim-airline-themes' }
|
||||
|
||||
-- Statusbar, colors and syntax
|
||||
use { 'vim-airline/vim-airline' }
|
||||
use { 'vim-airline/vim-airline-themes' }
|
||||
-- LSP and related
|
||||
use { 'neovim/nvim-lspconfig' }
|
||||
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
|
||||
use { 'neovim/nvim-lspconfig' }
|
||||
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
|
||||
-- Plugins to extend builtin language support
|
||||
use { 'cespare/vim-toml' }
|
||||
use { 'gleam-lang/gleam.vim' }
|
||||
use { 'rust-lang/rust.vim' }
|
||||
use { 'folke/neodev.nvim' }
|
||||
|
||||
-- Plugins to extend builtin language support
|
||||
use { 'cespare/vim-toml' }
|
||||
use { 'gleam-lang/gleam.vim' }
|
||||
use { 'rust-lang/rust.vim' }
|
||||
use { 'folke/neodev.nvim' }
|
||||
-- Git
|
||||
use {
|
||||
'NeogitOrg/neogit',
|
||||
requires = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "sindrets/diffview.nvim" },
|
||||
},
|
||||
}
|
||||
use { "lewis6991/gitsigns.nvim" }
|
||||
|
||||
-- Git
|
||||
use {
|
||||
'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' }
|
||||
-- Filesystem browser
|
||||
use { 'stevearc/oil.nvim' }
|
||||
|
||||
-- Misc
|
||||
use { 'jbyuki/venn.nvim' } -- ascii diagrams
|
||||
use { 'hashivim/vim-terraform' }
|
||||
end)
|
||||
|
||||
require('plugins.cmp')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local neogit = require('neogit')
|
||||
|
||||
neogit.setup { }
|
||||
neogit.setup {}
|
||||
|
||||
vim.keymap.set('n', '<C-x><C-g>', neogit.open, {})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
-- 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
|
||||
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
|
||||
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
|
|
|
@ -3,19 +3,20 @@ function _G.Toggle_venn()
|
|||
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
||||
if venn_enabled == "nil" then
|
||||
vim.b.venn_enabled = true
|
||||
vim.cmd[[setlocal ve=all]]
|
||||
vim.cmd [[setlocal ve=all]]
|
||||
-- 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", "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", "H", "<C-v>h: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", "L", "<C-v>l: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
|
||||
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
|
||||
vim.cmd[[setlocal ve=]]
|
||||
vim.cmd[[mapclear <buffer>]]
|
||||
vim.cmd [[setlocal ve=]]
|
||||
vim.cmd [[mapclear <buffer>]]
|
||||
vim.b.venn_enabled = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- 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
|
||||
vim.opt.exrc = 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)
|
||||
scopes[scope][key] = value
|
||||
|
@ -8,9 +8,9 @@ function utils.opt(scope, key, value)
|
|||
end
|
||||
|
||||
function utils.map(mode, lhs, rhs, opts)
|
||||
local options = { noremap = true, silent = true }
|
||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
local options = { noremap = true, silent = true }
|
||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
end
|
||||
|
||||
return utils
|
||||
|
|
Loading…
Reference in a new issue