<commit_before>"
" Sort imports
"
" 1. Java/Scala imports like java.util.UUID
" 2. Third party libraries
" 3. First party libraries
"
" author: <NAME> <<EMAIL>>
"

function! SortScalaImports()
  let curr = 0
  let first_line = -1
  let last_line = -1
  let trailing_newlines = 0
  let java_scala_imports = []
  let first_party_imports = []
  let third_party_imports = []

  " loop over lines in buffer
  while curr < line('$')

    let line = getline(curr)

    if line =~ "^import"
      if first_line == -1
        let first_line = curr
      endif

      if line =~ '^import \(java\(x\)\?\|scala\)\.'
        call add(java_scala_imports, line)
      elseif line =~ '^import \(de.\|controller\|util\)'
        call add(first_party_imports, line)
      else
        call add(third_party_imports, line)
      endif

      let trailing_newlines = 0
    elseif empty(line)
      let trailing_newlines = trailing_newlines + 1
    elseif first_line != -1
      let last_line = curr - trailing_newlines - 1
      " break out when you have found the first non-import line
      break
    endif

    let curr = curr + 1
  endwhile

  call cursor(first_line - 1, 0)
  let to_delete = last_line - first_line + 2
  execute 'd'to_delete

  call sort(java_scala_imports)
  call sort(first_party_imports)
  call sort(third_party_imports)<commit_msg>Add 'views' to first party imports<commit_after>"
" Sort imports
"
" 1. Java/Scala imports like java.util.UUID
" 2. Third party libraries
" 3. First party libraries
"
" author: <NAME> <<EMAIL>>
"

function! SortScalaImports()
  let curr = 0
  let first_line = -1
  let last_line = -1
  let trailing_newlines = 0
  let java_scala_imports = []
  let first_party_imports = []
  let third_party_imports = []

  " loop over lines in buffer
  while curr < line('$')

    let line = getline(curr)

    if line =~ "^import"
      if first_line == -1
        let first_line = curr
      endif

      if line =~ '^import \(java\(x\)\?\|scala\)\.'
        call add(java_scala_imports, line)
      elseif line =~ '^import \(de.\|controller\|util\|views\)'
        call add(first_party_imports, line)
      else
        call add(third_party_imports, line)
      endif

      let trailing_newlines = 0
    elseif empty(line)
      let trailing_newlines = trailing_newlines + 1
    elseif first_line != -1
      let last_line = curr - trailing_newlines - 1
      " break out when you have found the first non-import line
      break
    endif

    let curr = curr + 1
  endwhile

  call cursor(first_line - 1, 0)
  let to_delete = last_line - first_line + 2
  execute 'd'to_delete

  call sort(java_scala_imports)
  call sort(first_party_imports)
  call sort(third_party_imports)
{'fraction_non_alphanumeric': 0.10074074074074074, 'fraction_numerical': 0.011851851851851851, 'mean_word_length': 2.715268225584594, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1407371', 'n_tokens_mistral': 944, 'n_tokens_neox': 904, 'n_words': 264}