diff options
| author | Aotrix <[email protected]> | 2024-02-14 14:49:35 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2024-02-14 14:49:35 +0100 |
| commit | b917b82fdd914e8d18d80ec1b7c8b87d66ceeb9a (patch) | |
| tree | 6eec6f6917aafb352e01d597bfca6cb555ab775b /lua | |
added nvim config
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/autocomplete/autocomplete.lua | 101 | ||||
| -rw-r--r-- | lua/nvim_settings/remap.lua | 16 | ||||
| -rw-r--r-- | lua/nvim_settings/set.lua | 31 | ||||
| -rw-r--r-- | lua/statusline/statusline.lua | 40 | ||||
| -rw-r--r-- | lua/theme/gruvbox.lua | 1 | ||||
| -rw-r--r-- | lua/theme/kanagawa.lua | 1 | ||||
| -rw-r--r-- | lua/theme/seoul.lua | 1 | ||||
| -rw-r--r-- | lua/treesitter/treesitter.lua | 41 |
8 files changed, 232 insertions, 0 deletions
diff --git a/lua/autocomplete/autocomplete.lua b/lua/autocomplete/autocomplete.lua new file mode 100644 index 0000000..3e81bc6 --- /dev/null +++ b/lua/autocomplete/autocomplete.lua @@ -0,0 +1,101 @@ +local lspconfig = require('lspconfig') +lspconfig.pyright.setup{} +lspconfig.clangd.setup{} +require("mason").setup() +require("mason-lspconfig").setup() +local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() +lspconfig.pyright.setup({ + capabilities = lsp_capabilities, +}) + +vim.opt.completeopt = {'menu', 'menuone', 'noselect'} +local cmp = require('cmp') +local luasnip = require('luasnip') + +local select_opts = {behavior = cmp.SelectBehavior.Select} + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + sources = { + {name = 'path'}, + {name = 'nvim_lsp', keyword_length = 1}, + {name = 'buffer', keyword_length = 3}, + {name = 'luasnip', keyword_length = 2}, + }, + window = { + -- completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered() + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon = { + nvim_lsp = 'λ', + luasnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + + item.menu = menu_icon[entry.source.name] + return item + end, + }, + performance = { + max_view_entries = 7 + }, + mapping = { + ['<Up>'] = cmp.mapping.select_prev_item(select_opts), + ['<Down>'] = cmp.mapping.select_next_item(select_opts), + + ['<C-p>'] = cmp.mapping.select_prev_item(select_opts), + ['<C-n>'] = cmp.mapping.select_next_item(select_opts), + + ['<C-u>'] = cmp.mapping.scroll_docs(-4), + ['<C-d>'] = cmp.mapping.scroll_docs(4), + + ['<C-e>'] = cmp.mapping.abort(), + ['<C-y>'] = cmp.mapping.confirm({select = true}), + ['<CR>'] = cmp.mapping.confirm({select = false}), + + ['<C-f>'] = cmp.mapping(function(fallback) + if luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, {'i', 's'}), + + ['<C-b>'] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {'i', 's'}), + + ['<Tab>'] = cmp.mapping(function(fallback) + local col = vim.fn.col('.') - 1 + + if cmp.visible() then + cmp.select_next_item(select_opts) + elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + fallback() + else + cmp.complete() + end + end, {'i', 's'}), + + ['<S-Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item(select_opts) + else + fallback() + end + end, {'i', 's'}), + }, +}) + diff --git a/lua/nvim_settings/remap.lua b/lua/nvim_settings/remap.lua new file mode 100644 index 0000000..2e4bbe1 --- /dev/null +++ b/lua/nvim_settings/remap.lua @@ -0,0 +1,16 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "<leader>pv", vim.cmd.Ex) + +vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") +vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "<C-d>", "<C-d>zz") +vim.keymap.set("n", "<C-u>", "<C-u>zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +vim.keymap.set("x", "<leader>p", [["_dP]]) + +vim.keymap.set({"n", "v"}, "<leader>y", [["+y]]) +vim.keymap.set("n", "<leader>Y", [["+Y]]) diff --git a/lua/nvim_settings/set.lua b/lua/nvim_settings/set.lua new file mode 100644 index 0000000..44f703c --- /dev/null +++ b/lua/nvim_settings/set.lua @@ -0,0 +1,31 @@ +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +-- vim.opt.colorcolumn = "80" diff --git a/lua/statusline/statusline.lua b/lua/statusline/statusline.lua new file mode 100644 index 0000000..0297163 --- /dev/null +++ b/lua/statusline/statusline.lua @@ -0,0 +1,40 @@ +require('lualine').setup { + options = { + icons_enabled = false, + theme = 'material', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} diff --git a/lua/theme/gruvbox.lua b/lua/theme/gruvbox.lua new file mode 100644 index 0000000..869cc44 --- /dev/null +++ b/lua/theme/gruvbox.lua @@ -0,0 +1 @@ +vim.cmd([[colorscheme gruvbox]]) diff --git a/lua/theme/kanagawa.lua b/lua/theme/kanagawa.lua new file mode 100644 index 0000000..de4da4f --- /dev/null +++ b/lua/theme/kanagawa.lua @@ -0,0 +1 @@ +vim.cmd([[colorscheme kanagawa-dragon]]) diff --git a/lua/theme/seoul.lua b/lua/theme/seoul.lua new file mode 100644 index 0000000..daa643c --- /dev/null +++ b/lua/theme/seoul.lua @@ -0,0 +1 @@ +vim.cmd([[colorscheme seoul256]]) diff --git a/lua/treesitter/treesitter.lua b/lua/treesitter/treesitter.lua new file mode 100644 index 0000000..59d0d2f --- /dev/null +++ b/lua/treesitter/treesitter.lua @@ -0,0 +1,41 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "cpp", "lua", "vim", "vimdoc"}, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (or "all") + ignore_install = { "javascript" }, + + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + -- disable = { "c", "rust" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} |
