initial commit, pc config
This commit is contained in:
commit
139aac8fef
6 changed files with 394 additions and 0 deletions
202
config/nvim/init.lua
Normal file
202
config/nvim/init.lua
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
-- General
|
||||
vim.o.mouse = ""
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- Search
|
||||
vim.o.showmatch = true
|
||||
vim.o.ignorecase = true
|
||||
vim.o.hlsearch = true
|
||||
vim.o.wildmode = "longest,list"
|
||||
|
||||
-- Tab
|
||||
vim.o.tabstop = 4
|
||||
vim.o.shiftwidth = 4
|
||||
vim.o.autoindent = true
|
||||
-- vim.o.smartindent = true
|
||||
|
||||
-- Style
|
||||
vim.o.termguicolors = true
|
||||
-- set list listchars=tab:\▎\ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨
|
||||
-- hi NonText guifg=bg
|
||||
|
||||
-- Keybinds
|
||||
-- Remove arrow keys
|
||||
vim.keymap.set('', '<Up>', '')
|
||||
vim.keymap.set('', '<Down>', '')
|
||||
vim.keymap.set('', '<Left>', '')
|
||||
vim.keymap.set('', '<Right>', '')
|
||||
vim.keymap.set('i', '<Up>', '')
|
||||
vim.keymap.set('i', '<Down>', '')
|
||||
vim.keymap.set('i', '<Left>', '')
|
||||
vim.keymap.set('i', '<Right>', '')
|
||||
|
||||
-- LSP
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, bufopts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
vim.keymap.set('n', '<leader>s', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
|
||||
-- Terminal
|
||||
vim.keymap.set('', 'tt', ':terminal<CR>i')
|
||||
vim.keymap.set('t', '<ESC>', '<C-\\><C-n>')
|
||||
|
||||
-- Other
|
||||
vim.keymap.set('n', '<F2>', '<Cmd>tabnew $MYVIMRC<CR>')
|
||||
|
||||
-- bootstrap lazy.nvim
|
||||
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)
|
||||
|
||||
-- Plugins
|
||||
require("lazy").setup({
|
||||
-- dependencies
|
||||
"onsails/lspkind.nvim",
|
||||
"kyazdani42/nvim-web-devicons",
|
||||
"nvim-lua/plenary.nvim",
|
||||
|
||||
-- style
|
||||
"nvim-treesitter/nvim-treesitter", -- syntax highlight
|
||||
|
||||
-- themes
|
||||
"kdheepak/monochrome.nvim",
|
||||
"Domeee/mosel.nvim",
|
||||
"folke/tokyonight.nvim",
|
||||
"rose-pine/neovim",
|
||||
|
||||
-- integrations
|
||||
"lewis6991/gitsigns.nvim", -- git sign bar integration
|
||||
"nvim-telescope/telescope.nvim", -- fuzzy search
|
||||
|
||||
-- cmp
|
||||
"hrsh7th/nvim-cmp", -- autocompletion
|
||||
"hrsh7th/cmp-nvim-lsp", -- lsp source
|
||||
"hrsh7th/cmp-buffer", -- buffer source
|
||||
"hrsh7th/cmp-path", -- path source
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"L3MON4D3/LuaSnip", -- snippet engine
|
||||
|
||||
-- lsp
|
||||
"williamboman/mason.nvim", -- lsp auto install
|
||||
"williamboman/mason-lspconfig.nvim", -- auto lsp config
|
||||
"neovim/nvim-lspconfig", -- lsp config
|
||||
|
||||
-- formating
|
||||
"sbdchd/neoformat",
|
||||
|
||||
-- linting
|
||||
"mfussenegger/nvim-lint"
|
||||
})
|
||||
vim.cmd("colo mosel")
|
||||
|
||||
|
||||
-- treesitter
|
||||
require("nvim-treesitter").setup({
|
||||
highlight = {
|
||||
enable = true
|
||||
}
|
||||
})
|
||||
|
||||
-- gitsigns
|
||||
require('gitsigns').setup()
|
||||
vim.keymap.set('n', '<leader>gb', '<Cmd>Gitsigns blame_line<CR>')
|
||||
|
||||
-- telescope
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>ff', '<Cmd>Telescope find_files<CR>')
|
||||
vim.keymap.set('n', '<leader>fr', '<Cmd>Telescope oldfiles<CR>')
|
||||
vim.keymap.set('n', '<leader>fg', '<Cmd>Telescope live_grep<CR>')
|
||||
vim.keymap.set('n', '<leader>fs', '<Cmd>Telescope grep_string<CR>')
|
||||
vim.keymap.set('n', '<leader>fb', '<Cmd>Telescope buffers<CR>')
|
||||
vim.keymap.set('n', '<leader>fh', '<Cmd>Telescope help_tags<CR>')
|
||||
|
||||
-- cmp config
|
||||
local cmp = require("cmp")
|
||||
cmp.setup {
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- fancy icons and a name of kind
|
||||
vim_item.kind = require("lspkind").presets.default[vim_item.kind] ..
|
||||
" " .. vim_item.kind
|
||||
-- set a name for each source
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
path = "[Path]",
|
||||
-- snip = "[Snip]"
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
},
|
||||
mapping = {
|
||||
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
||||
["<Tab>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<Esc>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true
|
||||
}),
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
-- { name = "luasnip" }
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require 'luasnip'.lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
completion = { completeopt = "menu,menuone,noinsert" }
|
||||
}
|
||||
|
||||
-- mason
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup {
|
||||
automatic_enable = true
|
||||
}
|
||||
|
||||
vim.lsp.enable({
|
||||
'clangd',
|
||||
'hls'
|
||||
})
|
||||
|
||||
-- require('lint').linters_by_ft = {
|
||||
-- markdown = {'vale'},
|
||||
-- css = {"stylelint"},
|
||||
-- html = {"htmlhint"},
|
||||
-- }
|
||||
|
||||
-- vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
-- callback = function()
|
||||
-- require("lint").try_lint()
|
||||
-- end,
|
||||
-- })
|
||||
Loading…
Add table
Add a link
Reference in a new issue