diff --git a/init.lua b/init.lua index ee8ff02..7374c87 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,4 @@ require("config.init") require("keymap.key") vim.cmd('set number') +vim.keymap.set('v', '1f', vim.lsp.buf.format, bufopts) diff --git a/lua/config/cmp_config.lua b/lua/config/cmp_config.lua new file mode 100644 index 0000000..e8dd38d --- /dev/null +++ b/lua/config/cmp_config.lua @@ -0,0 +1,30 @@ +local cmp = require("cmp") +require("luasnip.loaders.from_vscode").lazy_load() +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'codeium' }, + }), + formatting = { + format = require('lspkind').cmp_format({ + mode = "symbol", + maxwidth = 50, + ellipsis_char = '...', + symbol_map = { Codeium = "", }, + }), + } +}) diff --git a/lua/config/lsp_config.lua b/lua/config/lsp_config.lua new file mode 100644 index 0000000..4778210 --- /dev/null +++ b/lua/config/lsp_config.lua @@ -0,0 +1,27 @@ +require("mason").setup({}) +require("mason-lspconfig").setup({ + ensured_install = { + "lua_ls", "pyright", + "vimls", + }, +}) +local on_attach = function(_, _) +vim.keymap.set('n', 'rn', vim.lsp.buf.rename, {}) +vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, {}) + +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) +vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {}) +vim.keymap.set('n', 'gr', vim.lsp.buf.references, {}) +vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) +end + +local capabilities = require("cmp_nvim_lsp").default_capabilities() + +require("lspconfig").lua_ls.setup({ +on_attach = on_attach, +capabilities = capabilities, +}) +require("lspconfig").pyright.setup({ +on_attach = on_attach, +capabilities = capabilities, +}) diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua new file mode 100644 index 0000000..e220ac7 --- /dev/null +++ b/lua/config/lualine.lua @@ -0,0 +1,40 @@ +require('lualine').setup({ + options = { + icons_enabled = true, + theme = 'auto', + 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/config/nvim_tree.lua b/lua/config/nvim_tree.lua new file mode 100644 index 0000000..d252bad --- /dev/null +++ b/lua/config/nvim_tree.lua @@ -0,0 +1,2 @@ +require("nvim-tree").setup() + diff --git a/lua/config/snippets.lua b/lua/config/snippets.lua new file mode 100644 index 0000000..de9e5d9 --- /dev/null +++ b/lua/config/snippets.lua @@ -0,0 +1,3 @@ +local ls = require("luasnip") +local s = ls.snippet +local t = ls.text_node diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua new file mode 100644 index 0000000..98f48ac --- /dev/null +++ b/lua/config/treesitter.lua @@ -0,0 +1,33 @@ +require('nvim-treesitter.configs').setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "python" }, + + -- 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 + -- 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, + }, +} diff --git a/lua/keymap/key.lua b/lua/keymap/key.lua index b78ec6c..879a4c7 100644 --- a/lua/keymap/key.lua +++ b/lua/keymap/key.lua @@ -1,6 +1,6 @@ local map = vim.keymap.set map("n", "ff", "Telescope fd") map("n", "th", "Telescope colorscheme") -map("n", "", "NvimTreeToggle", { desc = "Nvimtree Toggle window" }) -map("n", "", "NvimTreeFocus", { desc = "Nvimtree Focus window" }) +map("n", "", "NvimTreeToggle", { desc = "NvimTreeToggle window" }) +map("n", "", "NvimTreeFocus", { desc = "NvimTreeFocus window" }) diff --git a/lua/plugins/custom.lua b/lua/plugins/custom.lua deleted file mode 100644 index 8156afb..0000000 --- a/lua/plugins/custom.lua +++ /dev/null @@ -1,2 +0,0 @@ --- place your custom plugins here ONLY ---@type custom.plugins diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index c071fc0..ae3d0b7 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -4,7 +4,7 @@ return { { "folke/which-key.nvim", }, - { + { "folke/neoconf.nvim", cmd = "Neoconf", }, @@ -13,55 +13,39 @@ return { }, -- lsp config, nvim cmp { - "neovim/nvim-lspconfig", - lazy = false, - config = function() - end, - opts = { - ensure_install = { - "python", "html", - "bash", "css", - }, - }, - + "neovim/nvim-lspconfig", }, { - "hrsh7th/cmp-nvim-lsp", - opts = { - ensure_install = { - "pyright" - }, - }, + "hrsh7th/nvim-cmp", + config = function() + return require("config.cmp_config") + end }, { - "hrsh7th/cmp-buffer", + "hrsh7th/cmp-nvim-lsp", }, + -- and snippet { - "hrsh7th/cmp-path", + "williamboman/mason-lspconfig.nvim", + config = function() + return require("config.lsp_config") + end }, { - "hrsh7th/nvim-cmp", + "williamboman/mason.nvim", }, - -- mason nvim + -- completion ie snippet { - "williamboman/mason.nvim", - cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" }, - opts = { - ensured_install = { - "lua-language-server", "pyright", - }, - }, + "L3MON4D3/LuaSnip", + "rafamadriz/friendly-snippets", + "saadparwaiz1/cmp_luasnip", }, --treesitter { "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { - "lua", "vim", - "vimdoc", "pymanifest", - "python", "bash" - }, - }, + config = function() + return require("config.treesitter") + end }, -- telescope { @@ -69,11 +53,9 @@ return { }, { "nvim-tree/nvim-tree.lua", - lazy = false, config = function() - require("nvim-tree").setup({ - }) - end, + return require("config.nvim_tree") + end }, { "catppuccin/nvim", @@ -84,9 +66,26 @@ return { end }, { - "vim-airline/vim-airline", + "nvim-lualine/lualine.nvim", + dependencies = { 'nvim-tree/nvim-web-devicons' }, config = function() - vim.cmd('AirlineTheme catppuccin') - end + return require("config.lualine") + end, + }, + { + "Exafunction/codeium.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "hrsh7th/nvim-cmp", + }, + config = function() + require("codeium").setup({ + }) + end + }, + { + "onsails/lspkind.nvim", + }, + { }, }