From b48f9039c1263bb94c2879c3781503776466cfea Mon Sep 17 00:00:00 2001 From: Abdullah Bodur Date: Wed, 1 Oct 2025 02:32:11 +0200 Subject: [PATCH] configure --- init.lua | 74 +++++++++++++++++++++++++++++++++++-- lua/config/filetypes.lua | 22 +++++++++++ lua/config/lspconfig.lua | 53 +++++++++++++++----------- lua/plugins/colorscheme.lua | 30 ++++++++++++++- lua/plugins/lsp.lua | 28 +++++++++++++- lua/plugins/lualine.lua | 11 ++++++ lua/plugins/treesitter.lua | 2 +- 7 files changed, 191 insertions(+), 29 deletions(-) create mode 100644 lua/config/filetypes.lua create mode 100644 lua/plugins/lualine.lua diff --git a/init.lua b/init.lua index 923e583f..65fb9540 100644 --- a/init.lua +++ b/init.lua @@ -100,10 +100,14 @@ vim.g.have_nerd_font = false -- Make line numbers default -- vim.opt.number = true --- You can also add relative line numbers, to help with jumping. +-- You can also add reeative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! vim.opt.relativenumber = true +-- Ensure line numbers are always visible +vim.opt.numberwidth = 4 -- Width of number column +vim.opt.signcolumn = 'yes' -- Always show sign column + -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -144,8 +148,8 @@ vim.opt.splitbelow = true -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` -- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.list = false -- Disable showing whitespace characters +-- vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Preview substitutions live, as you type! vim.opt.inccommand = 'split' @@ -156,6 +160,65 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +-- Configure fillchars to show empty lines +vim.opt.fillchars = { + eob = ' ', -- End of buffer character (empty line indicator) + fold = ' ', -- Fold indicator + foldopen = '▼', -- Fold open indicator + foldclose = '▶', -- Fold close indicator + foldsep = '│', -- Fold separator + diff = '╱', -- Diff indicator + msgsep = ' ', -- Message separator + vert = '│', -- Vertical split character + horiz = '─', -- Horizontal split character + horizup = '┴', -- Horizontal up split character + horizdown = '┬', -- Horizontal down split character +} + +-- Show empty lines at the end of buffer +vim.opt.display = 'lastline' + +-- Enable virtual text for better empty line visibility +vim.opt.virtualedit = 'onemore' + +-- Indent configuration +vim.opt.tabstop = 2 -- Number of spaces a tab counts for +vim.opt.shiftwidth = 2 -- Number of spaces to use for each step of (auto)indent +vim.opt.softtabstop = 2 -- Number of spaces that a tab counts for while performing editing operations +vim.opt.expandtab = true -- Use spaces instead of tabs +vim.opt.smartindent = true -- Smart autoindenting when starting a new line +vim.opt.autoindent = true -- Copy indent from current line when starting a new line + +-- Filetype-specific indent settings +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'python', 'yaml', 'yml' }, + callback = function() + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + vim.opt_local.softtabstop = 2 + end, +}) + +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'go', 'rust' }, + callback = function() + vim.opt_local.tabstop = 4 + vim.opt_local.shiftwidth = 4 + vim.opt_local.softtabstop = 4 + vim.opt_local.expandtab = false -- Use tabs for Go and Rust + end, +}) + +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'kotlin', 'java', 'javascript', 'typescript', 'lua' }, + callback = function() + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + vim.opt_local.softtabstop = 2 + vim.opt_local.expandtab = true + end, +}) + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -218,6 +281,9 @@ vim.opt.rtp:prepend(lazypath) -- Load LSP configurations require 'config.lspconfig' require 'config.diagnostic' + +-- Load filetype configurations +require 'config.filetypes' -- [[ Configure and install plugins ]] -- -- To check the current status of your plugins, run @@ -285,6 +351,8 @@ require('lazy').setup({ -- LSP Plugins require 'plugins.lazydev', + -- nvim bar plugin + require 'plugins.lualine', require 'plugins.java', require 'plugins.conform', diff --git a/lua/config/filetypes.lua b/lua/config/filetypes.lua new file mode 100644 index 00000000..d31cf2e5 --- /dev/null +++ b/lua/config/filetypes.lua @@ -0,0 +1,22 @@ +-- Filetype detection configuration +-- This file ensures proper filetype detection for various languages + +-- Kotlin filetype detection +vim.filetype.add({ + extension = { + kt = 'kotlin', + kts = 'kotlin', + }, + pattern = { + ['.*%.kt$'] = 'kotlin', + ['.*%.kts$'] = 'kotlin', + }, +}) + +-- Ensure treesitter highlights are applied +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'kotlin', 'java' }, + callback = function() + vim.treesitter.start() + end, +}) diff --git a/lua/config/lspconfig.lua b/lua/config/lspconfig.lua index 6f4bbb70..b62c4eb7 100644 --- a/lua/config/lspconfig.lua +++ b/lua/config/lspconfig.lua @@ -1,25 +1,34 @@ --- LSP configuration for Kotlin +-- LSP configuration for Kotlin and Java with Maven support -- This file contains LSP server configurations that are loaded on startup + +return function() + -- Kotlin LSP configuration (Official Kotlin LSP) + vim.lsp.config('kotlin_language_server', { + filetypes = { 'kotlin' }, + root_markers = { + 'pom.xml', + 'build.gradle', + 'build.gradle.kts', + 'settings.gradle', + 'settings.gradle.kts' + }, + single_file_support = true, + }) + vim.lsp.enable('kotlin_language_server') --- Enable Kotlin LSP -vim.lsp.config('kotlin_lsp', { - filetypes = { 'kotlin' }, - root_markers = { - 'settings.gradle', - 'settings.gradle.kts', - 'pom.xml', - }, -}) + vim.lsp.set_log_level("debug") -vim.lsp.config('jdtls', { - filetypes = { 'java' }, - root_markers = { - 'pom.xml', - 'build.gradle', - 'build.gradle.kts', - }, -}) - -vim.lsp.enable('kotlin_lsp') - -vim.diagnostic.enable() \ No newline at end of file + -- Java LSP configuration + vim.lsp.config('jdtls', { + filetypes = { 'java' }, + root_markers = { + 'pom.xml', + 'build.gradle', + 'build.gradle.kts', + '.git' + }, + single_file_support = true, + + }) + vim.lsp.enable('jdtls') +end \ No newline at end of file diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 4e438dda..48f7639f 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,6 +1,32 @@ --- VSCode-inspired colorscheme configuration +-- Kanagawa colorscheme configuration return { - "rebelot/kanagawa.nvim" + "rebelot/kanagawa.nvim", + config = function() + require('kanagawa').setup({ + -- Available modes: 'wave', 'lotus', 'dragon' + -- 'wave' - Default, balanced colors + -- 'lotus' - Lighter, more pastel colors + -- 'dragon' - Darker, more vibrant colors + theme = "wave", -- Change this to 'lotus' or 'dragon' for different modes + + -- Additional options + transparent = false, + terminal_colors = true, + colors = { + -- You can override specific colors here if needed + -- palette = {}, + -- theme = {}, + }, + overrides = function(colors) + return { + -- Custom overrides can go here + } + end, + }) + + -- Set the colorscheme + vim.cmd("colorscheme kanagawa") + end, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index a2b4f84d..99d65498 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,2 +1,28 @@ -return {} +return { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + }, + config = function() + require('mason').setup() + require('mason-lspconfig').setup({ + ensure_installed = { 'kotlin_language_server', 'jdtls' }, + automatic_installation = true, + handlers = { + -- Default handler for all servers + function(server_name) + vim.lsp.config(server_name, {}) + end, + -- Custom handler for specific servers + kotlin_language_server = function() + require('config.lspconfig')() + end, + jdtls = function() + require('config.lspconfig')() + end, + } + }) + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 00000000..eea62bbd --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,11 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup({ + options = { + theme = "tomorrow_night", + } + }) + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 83cc999e..04d15fde 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -4,7 +4,7 @@ return { build = ':TSUpdate', main = 'nvim-treesitter.configs', opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'java', 'kotlin' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'java', 'kotlin', 'javascript' }, auto_install = true, highlight = { enable = true,